mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-23 04:21:52 -06:00
sqlitetypes: extract unique information of columns
This commit is contained in:
@@ -20,6 +20,8 @@ QString Field::toString(const QString& indent, const QString& sep) const
|
||||
str += " CHECK(" + m_check + ")";
|
||||
if(m_autoincrement)
|
||||
str += " PRIMARY KEY AUTOINCREMENT";
|
||||
if(m_unique)
|
||||
str += " UNIQUE";
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -346,6 +348,7 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
|
||||
bool autoincrement = false;
|
||||
bool primarykey = false;
|
||||
bool notnull = false;
|
||||
bool unique = false;
|
||||
QString defaultvalue;
|
||||
QString check;
|
||||
|
||||
@@ -404,12 +407,17 @@ void CreateTableWalker::parsecolumn(FieldPtr& f, antlr::RefAST c)
|
||||
defaultvalue = concatTextAST(con);
|
||||
}
|
||||
break;
|
||||
case sqlite3TokenTypes::UNIQUE:
|
||||
{
|
||||
unique = true;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
c = c->getNextSibling();
|
||||
}
|
||||
|
||||
f = FieldPtr( new Field(columnname, type, notnull, defaultvalue, check, primarykey));
|
||||
f = FieldPtr( new Field(columnname, type, notnull, defaultvalue, check, primarykey, unique));
|
||||
f->setAutoIncrement(autoincrement);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ public:
|
||||
bool notnull = false,
|
||||
const QString& defaultvalue = "",
|
||||
const QString& check = "",
|
||||
bool pk = false)
|
||||
bool pk = false,
|
||||
bool unique = false)
|
||||
: m_name(name)
|
||||
, m_type(type)
|
||||
, m_notnull(notnull)
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
, m_defaultvalue(defaultvalue)
|
||||
, m_autoincrement(false)
|
||||
, m_primaryKey(pk)
|
||||
, m_unique(unique)
|
||||
{}
|
||||
|
||||
QString toString(const QString& indent = "\t", const QString& sep = "\t") const;
|
||||
@@ -38,6 +40,7 @@ public:
|
||||
void setDefaultValue(const QString& defaultvalue) { m_defaultvalue = defaultvalue; }
|
||||
void setAutoIncrement(bool autoinc) { m_autoincrement = autoinc; }
|
||||
void setPrimaryKey(bool pk) { m_primaryKey = pk; }
|
||||
void setUnique(bool u) { m_unique = u; }
|
||||
|
||||
bool isText() const;
|
||||
bool isInteger() const;
|
||||
@@ -49,6 +52,7 @@ public:
|
||||
const QString& defaultValue() const { return m_defaultvalue; }
|
||||
bool autoIncrement() const { return m_autoincrement; }
|
||||
bool primaryKey() const { return m_primaryKey; }
|
||||
bool unique() const { return m_unique; }
|
||||
|
||||
static QStringList Datatypes;
|
||||
private:
|
||||
@@ -59,6 +63,7 @@ private:
|
||||
QString m_defaultvalue;
|
||||
bool m_autoincrement; //! this is stored here for simplification
|
||||
bool m_primaryKey;
|
||||
bool m_unique;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<Field> FieldPtr;
|
||||
|
||||
Reference in New Issue
Block a user