Fall back to asking SQLite when parsing a table schema has failed

When parsing a table schema has failed, fall back to the PRAGMA provided
by SQLite to give us some information about the layout of the table.
This does not give us as much information but it is definitely better
than no information at all. The main aim here is to fix the case where
we are dealing with a virtual table which we failed to parse, and we
now do not even know it is a virtual table.

See issue #2187.
This commit is contained in:
Martin Kleusberg
2020-05-06 15:47:13 +02:00
parent 31ded8a8d9
commit 139de6690a

View File

@@ -1920,12 +1920,17 @@ void DBBrowserDB::updateSchema()
else
return false;
// If parsing wasn't successful set the object name manually, so that at least the name is going to be correct
// If parsing wasn't successful set the object name and SQL manually, so that at least the name is going to be correct
if(!object->fullyParsed())
{
object->setName(val_name);
object->setOriginalSql(val_sql);
}
// For virtual tables and views query the column list using the SQLite pragma because for both we can't yet rely on our grammar parser
if((object->type() == sqlb::Object::Types::Table && std::dynamic_pointer_cast<sqlb::Table>(object)->isVirtual()) || object->type() == sqlb::Object::Types::View)
// For virtual tables, views, and not fully parsed tables query the column list using the SQLite pragma because for both we can't yet rely on our grammar parser
if(!object->fullyParsed() ||
(object->type() == sqlb::Object::Types::Table && std::dynamic_pointer_cast<sqlb::Table>(object)->isVirtual()) ||
object->type() == sqlb::Object::Types::View)
{
const auto columns = queryColumnInformation(schema_name, val_name);