mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-04-27 23:52:34 -05:00
grammar: Add support for CHECK table constraints
This adds support for CHECK table constraints. We already had support for CHECK column constraints and still mostly use that but with this commit there are no more hickups when encountering such a table. It also adds basic support for editing those tables: the CHECK constraint isn't removed anymore when editing a different part of the table. Example: CREATE TABLE test( a int CHECK a IN(1,2,3), -- This was supported before b int, CHECK b IN (1,2,3) -- This is added by this commit );
This commit is contained in:
@@ -108,6 +108,7 @@ public:
|
||||
PrimaryKeyConstraintType,
|
||||
UniqueConstraintType,
|
||||
ForeignKeyConstraintType,
|
||||
CheckConstraintType,
|
||||
};
|
||||
|
||||
Constraint(const QString& name = QString())
|
||||
@@ -183,6 +184,25 @@ public:
|
||||
virtual ConstraintTypes type() const { return PrimaryKeyConstraintType; }
|
||||
};
|
||||
|
||||
class CheckConstraint : public Constraint
|
||||
{
|
||||
public:
|
||||
CheckConstraint(const QString& expr = QString())
|
||||
: m_expression(expr)
|
||||
{
|
||||
}
|
||||
|
||||
void setExpression(const QString& expr) { m_expression = expr; }
|
||||
QString expression() const { return m_expression; }
|
||||
|
||||
virtual QString toSql(const FieldVector& applyOn) const;
|
||||
|
||||
virtual ConstraintTypes type() const { return CheckConstraintType; }
|
||||
|
||||
private:
|
||||
QString m_expression;
|
||||
};
|
||||
|
||||
class Field
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user