Skip to content

Commit

Permalink
Fall back to asking SQLite when parsing a table schema has failed
Browse files Browse the repository at this point in the history
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 sqlitebrowser#2187.
  • Loading branch information
MKleusberg committed May 6, 2020
1 parent 31ded8a commit 139de66
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 139de66

Please sign in to comment.