9 namespace Deveel.Data.Sql.Compile {
14 const string sql =
"ALTER TABLE test ADD COLUMN b INT NOT NULL";
16 var result = Compile(sql);
17 Assert.IsNotNull(result);
18 Assert.IsFalse(result.HasErrors);
19 Assert.IsNotEmpty(result.Statements);
20 Assert.AreEqual(1, result.Statements.Count);
22 var statement = result.Statements.First();
24 Assert.IsNotNull(statement);
29 Assert.AreEqual(
"test", alterStatement.TableName.FullName);
33 Assert.AreEqual(
"b", alterAction.Column.ColumnName);
34 Assert.IsInstanceOf<
NumericType>(alterAction.Column.ColumnType);
35 Assert.IsTrue(alterAction.Column.IsNotNull);
41 const string sql =
"ALTER TABLE test ADD COLUMN b INT NOT NULL ADD c VARCHAR DEFAULT 'test'";
43 var result = Compile(sql);
44 Assert.IsNotNull(result);
45 Assert.IsFalse(result.HasErrors);
46 Assert.IsNotEmpty(result.Statements);
47 Assert.AreEqual(2, result.Statements.Count);
52 const string sql =
"ALTER TABLE test ADD COLUMN b INT NOT NULL ADD CONSTRAINT c UNIQUE(a, b)";
54 var result = Compile(sql);
55 Assert.IsNotNull(result);
56 Assert.IsFalse(result.HasErrors);
57 Assert.IsNotEmpty(result.Statements);
58 Assert.AreEqual(2, result.Statements.Count);
60 var firstStatement = result.Statements.ElementAt(0);
61 var secondStatement = result.Statements.ElementAt(1);
63 Assert.IsNotNull(firstStatement);
64 Assert.IsNotNull(secondStatement);
78 const string sql =
"ALTER TABLE test ADD CONSTRAINT c PRIMARY KEY(id)";
80 var result = Compile(sql);
81 Assert.IsNotNull(result);
82 Assert.IsFalse(result.HasErrors);
83 Assert.IsNotEmpty(result.Statements);
84 Assert.AreEqual(1, result.Statements.Count);
86 var statement = result.Statements.First();
88 Assert.IsNotNull(statement);
93 Assert.AreEqual(
"test", alterStatement.TableName.FullName);
99 const string sql =
"ALTER TABLE test DROP COLUMN b";
101 var result = Compile(sql);
102 Assert.IsNotNull(result);
103 Assert.IsFalse(result.HasErrors);
104 Assert.IsNotEmpty(result.Statements);
105 Assert.AreEqual(1, result.Statements.Count);
107 var statement = result.Statements.ElementAt(0);
void AddPrimaryKeyContraint()
void AddMultipleColumns()
void AddColumnsAndUniqeContraints()