16 using System.Collections.Generic;
24 using NUnit.Framework;
26 namespace Deveel.Data.Sql.Statements {
39 Query.CreateTable(tableInfo);
40 Query.AddPrimaryKey(tableInfo.TableName,
"id",
"PK_TEST_TABLE");
45 const string sql =
"INSERT INTO test_table (first_name, last_name, birth_date) "+
46 "VALUES ('Antonello', 'Provenzano', TOODATE('1980-06-04'))";
48 IEnumerable<SqlStatement> statements = null;
50 Assert.IsNotNull(statements);
52 var statementList = statements.ToList();
53 Assert.IsNotEmpty(statementList);
54 Assert.AreEqual(1, statementList.Count);
56 var statement = statementList[0];
60 Assert.AreEqual(
"test_table", insertStatement.TableName);
61 Assert.AreEqual(3, insertStatement.ColumnNames.Count());
62 Assert.AreEqual(1, insertStatement.Values.Count());
67 const string sql =
"INSERT INTO test_table (first_name, last_name, birth_date) " +
68 "VALUES ('Antonello', 'Provenzano', TOODATE('1980-06-04')), " +
69 "('Sebastiano', 'Provenzano', TODATE('1981-08-27'))";
71 IEnumerable<SqlStatement> statements = null;
73 Assert.IsNotNull(statements);
75 var statementList = statements.ToList();
76 Assert.IsNotEmpty(statementList);
77 Assert.AreEqual(1, statementList.Count);
79 var statement = statementList[0];
83 Assert.AreEqual(
"test_table", insertStatement.TableName);
84 Assert.AreEqual(3, insertStatement.ColumnNames.Count());
85 Assert.AreEqual(2, insertStatement.Values.Count());
91 "INSERT INTO test_table SET first_name = 'Antonello', last_name = 'Provenzano', birth_date = TODATE('1980-06-04')";
93 IEnumerable<SqlStatement> statements = null;
95 Assert.IsNotNull(statements);
97 var statementList = statements.ToList();
98 Assert.IsNotEmpty(statementList);
99 Assert.AreEqual(1, statementList.Count);
101 var statement = statementList[0];
105 Assert.AreEqual(
"test_table", insertStatement.TableName);
106 Assert.AreEqual(3, insertStatement.ColumnNames.Count());
107 Assert.AreEqual(1, insertStatement.Values.Count());
112 const string sql =
"INSERT INTO test_table FROM (SELECT * FROM table2 WHERE arg1 = 1)";
114 IEnumerable<SqlStatement> statements = null;
116 Assert.IsNotNull(statements);
118 var statementList = statements.ToList();
119 Assert.IsNotEmpty(statementList);
120 Assert.AreEqual(1, statementList.Count);
122 var statement = statementList[0];
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
static BooleanType Boolean()
static NumericType Integer()
Describes the name of an object within a database.
Represents the foundation class of SQL statements to be executed.
void ParseValuesInsert_OneRow()
void AddColumn(ColumnInfo column)
Adds a new column to the table at the last position of the columns list in the table metadata...
static DateType DateTime()
static SqlReferenceExpression Reference(ObjectName objectName)
static StringType String()
Defines the base class for instances that represent SQL expression tree nodes.
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
static IEnumerable< SqlStatement > Parse(string sqlSource)
Parses a given string into one of more statements.
Defines the metadata properties of a table existing within a database.
void ParseValueInsert_MultipleRows()