9 namespace Deveel.Data.Sql.Compile {
14 const string sql =
"CREATE TABLE test (a INT NOT NULL, b VARCHAR NULL)";
16 var result = Compile(sql);
17 Assert.IsNotNull(result);
18 Assert.IsFalse(result.HasErrors);
19 Assert.AreEqual(1, result.Statements.Count);
23 Assert.IsNotNull(statement);
28 Assert.IsNotNullOrEmpty(createTable.TableName);
29 Assert.AreEqual(
"test", createTable.TableName);
30 Assert.IsFalse(createTable.Temporary);
31 Assert.IsFalse(createTable.IfNotExists);
33 Assert.AreEqual(2, createTable.Columns.Count);
34 Assert.AreEqual(
"a", createTable.Columns[0].ColumnName);
35 Assert.IsTrue(createTable.Columns[0].IsNotNull);
37 Assert.AreEqual(
"b", createTable.Columns[1].ColumnName);
38 Assert.IsFalse(createTable.Columns[1].IsNotNull);
43 const string sql =
"CREATE TABLE test (id INT IDENTITY, name VARCHAR NOT NULL)";
45 var result = Compile(sql);
46 Assert.IsNotNull(result);
47 Assert.IsFalse(result.HasErrors);
48 Assert.AreEqual(1, result.Statements.Count);
52 Assert.IsNotNull(statement);
57 Assert.IsNotNullOrEmpty(createTable.TableName);
58 Assert.AreEqual(
"test", createTable.TableName);
59 Assert.IsFalse(createTable.Temporary);
60 Assert.IsFalse(createTable.IfNotExists);
62 Assert.AreEqual(2, createTable.Columns.Count);
63 Assert.IsTrue(createTable.Columns[0].IsIdentity);
64 Assert.IsNotNull(createTable.Columns[0].DefaultExpression);
70 const string sql =
"CREATE TABLE test (a VARCHAR DEFAULT 'one')";
72 var result = Compile(sql);
73 Assert.IsNotNull(result);
74 Assert.IsFalse(result.HasErrors);
75 Assert.AreEqual(1, result.Statements.Count);
79 Assert.IsNotNull(statement);
84 Assert.IsNotNullOrEmpty(createTable.TableName);
85 Assert.AreEqual(
"test", createTable.TableName);
87 Assert.AreEqual(1, createTable.Columns.Count);
88 Assert.IsNotNull(createTable.Columns[0].DefaultExpression);
94 const string sql =
"CREATE TABLE test (id INT NOT NULL, UNIQUE(id))";
96 var result = Compile(sql);
97 Assert.IsNotNull(result);
98 Assert.IsFalse(result.HasErrors);
99 Assert.AreEqual(2, result.Statements.Count);
106 Assert.IsNotNull(statement);
111 Assert.IsNotNullOrEmpty(createTable.TableName);
112 Assert.AreEqual(
"test", createTable.TableName);
117 const string sql =
"CREATE TABLE test (id INT NOT NULL PRIMARY KEY)";
119 var result = Compile(sql);
120 Assert.IsNotNull(result);
121 Assert.IsFalse(result.HasErrors);
122 Assert.AreEqual(2, result.Statements.Count);
129 Assert.IsNotNull(statement);
134 Assert.IsNotNullOrEmpty(createTable.TableName);
135 Assert.AreEqual(
"test", createTable.TableName);
The statement object used to create a table in a database.
void WithIdentityColumn()
An expression that holds a constant value.
void WithColumnConstraints()