forked from qt-creator/qt-creator
Sqlite: Add unique index to table
Some times we need the constraint for an index. Change-Id: I81332238d36b88196ef03e26b4edcc1307de46e0 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@ namespace {
|
||||
|
||||
using Sqlite::Exception;
|
||||
using Sqlite::Index;
|
||||
using Sqlite::IndexType;
|
||||
|
||||
TEST(Index, OneColumn)
|
||||
{
|
||||
@@ -63,4 +64,13 @@ TEST(Index, EmptyColumns)
|
||||
|
||||
ASSERT_THROW(index.sqlStatement(), Exception);
|
||||
}
|
||||
|
||||
TEST(Index, UniqueIndex)
|
||||
{
|
||||
Index index{"tableName", {"column1"}, IndexType::Unique};
|
||||
|
||||
auto sqlStatement = index.sqlStatement();
|
||||
|
||||
ASSERT_THAT(sqlStatement, Eq("CREATE UNIQUE INDEX IF NOT EXISTS index_tableName_column1 ON tableName(column1)"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user