Make virtual tables browseable

See issue #917.
This commit is contained in:
Martin Kleusberg
2017-01-20 23:14:06 +01:00
parent e43dbddbd3
commit 97b5e4faf3
2 changed files with 9 additions and 2 deletions

View File

@@ -1258,6 +1258,15 @@ void DBBrowserDB::updateSchema( )
obj.object = sqlb::Object::parseSQL(type, val_sql);
if(val_temp == "1")
obj.object->setTemporary(true);
// For virtual tables query the column list using the SQLite pragma
if(type == sqlb::Object::ObjectTypes::Table && obj.object.dynamicCast<sqlb::Table>()->isVirtual())
{
sqlb::TablePtr tab = obj.object.dynamicCast<sqlb::Table>();
auto columns = queryColumnInformation(val_name);
foreach(const auto& column, columns)
tab->addField(sqlb::FieldPtr(new sqlb::Field(column.first, column.second)));
}
} else if(type == sqlb::Object::ObjectTypes::View) {
// For views we currently can't rely on our grammar parser to get the column list. Use the pragma offered by SQLite instead
auto columns = queryColumnInformation(val_name);

View File

@@ -520,8 +520,6 @@ TablePtr CreateTableWalker::table()
tab->setVirtualUsing(concatTextAST(s, true));
tab->setFullyParsed(false);
// TODO Maybe get the column list using the 'pragma table_info()' approach we're using for views
return TablePtr(tab);
}