grammar: Also parse foreign key clauses inside column definitions

Also parse foreign key clauses used inside column definitions as opposed
to just parsing those in the table constraints.

See issue #227.
This commit is contained in:
Martin Kleusberg
2015-03-14 00:56:08 +01:00
parent 50c034012f
commit b266f6f547

View File

@@ -423,6 +423,7 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
bool unique = false;
QString defaultvalue;
QString check;
QString foreignKey;
colname = columnname(c);
c = c->getNextSibling(); //type?
@@ -487,6 +488,12 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
unique = true;
}
break;
case sqlite3TokenTypes::REFERENCES:
{
con = con->getNextSibling(); // REFERENCES
foreignKey = concatTextAST(con, true);
}
break;
default:
{
m_bModifySupported = false;
@@ -498,6 +505,7 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
f = FieldPtr( new Field(colname, type, notnull, defaultvalue, check, primarykey, unique));
f->setAutoIncrement(autoincrement);
f->setForeignKey(foreignKey);
}
} //namespace sqlb