DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Private Member Functions | List of all members
Deveel.Data.Sql.Statements.InsertIntoStatementTests Class Reference
Inheritance diagram for Deveel.Data.Sql.Statements.InsertIntoStatementTests:
Deveel.Data.ContextBasedTest

Public Member Functions

void ParseValuesInsert_OneRow ()
 
void ParseValueInsert_MultipleRows ()
 
void ParserSetInsert ()
 
void ParseInsertSelect ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Private Member Functions

void CreateTestTable ()
 

Additional Inherited Members

- Protected Member Functions inherited from Deveel.Data.ContextBasedTest
virtual void RegisterServices (ServiceContainer container)
 
virtual ISystem CreateSystem ()
 
virtual IDatabase CreateDatabase (ISystem system, IConfiguration configuration)
 
virtual ISession CreateAdminSession (IDatabase database)
 
virtual IQuery CreateQuery (ISession session)
 
ISession CreateUserSession (string userName, string password)
 
virtual void OnSetUp (string testName)
 
virtual void OnTearDown ()
 
- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 
- Properties inherited from Deveel.Data.ContextBasedTest
virtual bool SingleContext [get]
 
IQuery Query [get, private set]
 
ISystem System [get, private set]
 
IDatabase Database [get, private set]
 
ISession Session [get, private set]
 

Detailed Description

Definition at line 28 of file InsertIntoStatementTests.cs.

Member Function Documentation

void Deveel.Data.Sql.Statements.InsertIntoStatementTests.CreateTestTable ( )
inlineprivate

Definition at line 29 of file InsertIntoStatementTests.cs.

29  {
30  var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
31  var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
32  idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUE_KEY",
33  new SqlExpression[] { SqlExpression.Reference(tableInfo.TableName) });
34  tableInfo.AddColumn("first_name", PrimitiveTypes.String());
35  tableInfo.AddColumn("last_name", PrimitiveTypes.String());
36  tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime());
37  tableInfo.AddColumn("active", PrimitiveTypes.Boolean());
38 
39  Query.CreateTable(tableInfo);
40  Query.AddPrimaryKey(tableInfo.TableName, "id", "PK_TEST_TABLE");
41  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
void AddColumn(ColumnInfo column)
Adds a new column to the table at the last position of the columns list in the table metadata...
Definition: TableInfo.cs:230
static SqlReferenceExpression Reference(ObjectName objectName)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
void Deveel.Data.Sql.Statements.InsertIntoStatementTests.ParseInsertSelect ( )
inline

Definition at line 111 of file InsertIntoStatementTests.cs.

111  {
112  const string sql = "INSERT INTO test_table FROM (SELECT * FROM table2 WHERE arg1 = 1)";
113 
114  IEnumerable<SqlStatement> statements = null;
115  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(Query.Context, sql));
116  Assert.IsNotNull(statements);
117 
118  var statementList = statements.ToList();
119  Assert.IsNotEmpty(statementList);
120  Assert.AreEqual(1, statementList.Count);
121 
122  var statement = statementList[0];
123  Assert.IsInstanceOf<InsertSelectStatement>(statement);
124  }
IQueryContext Context
Definition: Query.cs:68
void Deveel.Data.Sql.Statements.InsertIntoStatementTests.ParserSetInsert ( )
inline

Definition at line 89 of file InsertIntoStatementTests.cs.

89  {
90  const string sql =
91  "INSERT INTO test_table SET first_name = 'Antonello', last_name = 'Provenzano', birth_date = TODATE('1980-06-04')";
92 
93  IEnumerable<SqlStatement> statements = null;
94  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(Query.Context, sql));
95  Assert.IsNotNull(statements);
96 
97  var statementList = statements.ToList();
98  Assert.IsNotEmpty(statementList);
99  Assert.AreEqual(1, statementList.Count);
100 
101  var statement = statementList[0];
102  Assert.IsInstanceOf<InsertStatement>(statement);
103 
104  var insertStatement = (InsertStatement)statement;
105  Assert.AreEqual("test_table", insertStatement.TableName);
106  Assert.AreEqual(3, insertStatement.ColumnNames.Count());
107  Assert.AreEqual(1, insertStatement.Values.Count());
108  }
IQueryContext Context
Definition: Query.cs:68
void Deveel.Data.Sql.Statements.InsertIntoStatementTests.ParseValueInsert_MultipleRows ( )
inline

Definition at line 66 of file InsertIntoStatementTests.cs.

66  {
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'))";
70 
71  IEnumerable<SqlStatement> statements = null;
72  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(Query.Context, sql));
73  Assert.IsNotNull(statements);
74 
75  var statementList = statements.ToList();
76  Assert.IsNotEmpty(statementList);
77  Assert.AreEqual(1, statementList.Count);
78 
79  var statement = statementList[0];
80  Assert.IsInstanceOf<InsertStatement>(statement);
81 
82  var insertStatement = (InsertStatement)statement;
83  Assert.AreEqual("test_table", insertStatement.TableName);
84  Assert.AreEqual(3, insertStatement.ColumnNames.Count());
85  Assert.AreEqual(2, insertStatement.Values.Count());
86  }
IQueryContext Context
Definition: Query.cs:68
void Deveel.Data.Sql.Statements.InsertIntoStatementTests.ParseValuesInsert_OneRow ( )
inline

Definition at line 44 of file InsertIntoStatementTests.cs.

44  {
45  const string sql = "INSERT INTO test_table (first_name, last_name, birth_date) "+
46  "VALUES ('Antonello', 'Provenzano', TOODATE('1980-06-04'))";
47 
48  IEnumerable<SqlStatement> statements = null;
49  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(Query.Context, sql));
50  Assert.IsNotNull(statements);
51 
52  var statementList = statements.ToList();
53  Assert.IsNotEmpty(statementList);
54  Assert.AreEqual(1, statementList.Count);
55 
56  var statement = statementList[0];
57  Assert.IsInstanceOf<InsertStatement>(statement);
58 
59  var insertStatement = (InsertStatement) statement;
60  Assert.AreEqual("test_table", insertStatement.TableName);
61  Assert.AreEqual(3, insertStatement.ColumnNames.Count());
62  Assert.AreEqual(1, insertStatement.Values.Count());
63  }
IQueryContext Context
Definition: Query.cs:68

The documentation for this class was generated from the following file: