DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
CursorTests.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2014 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 using System;
16 
17 using Deveel.Data.Sql.Cursors;
19 using Deveel.Data.Sql.Tables;
20 using Deveel.Data.Types;
21 
22 using NUnit.Framework;
23 
24 namespace Deveel.Data.Sql {
25  [TestFixture]
26  public class CursorTests : ContextBasedTest {
27  protected override ISession CreateAdminSession(IDatabase database) {
28  using (var session = base.CreateAdminSession(database)) {
29  using (var query = session.CreateQuery()) {
30  var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
31  tableInfo.AddColumn("a", PrimitiveTypes.Integer());
32  tableInfo.AddColumn("b", PrimitiveTypes.String(), false);
33 
34  query.CreateTable(tableInfo, false, false);
35  query.Commit();
36  }
37  }
38 
39  return base.CreateAdminSession(database);
40  }
41 
42  [Test]
43  public void DeclareInsensitiveCursor() {
44  var query = new SqlQueryExpression(new []{new SelectColumn(SqlExpression.Constant("*")) });
45  query.FromClause = new FromClause();
46  query.FromClause.AddTable("test_table");
47 
48  Assert.DoesNotThrow(() => Query.DeclareInsensitiveCursor("c1", query));
49 
50  var exists = Query.ObjectExists(DbObjectType.Cursor, new ObjectName("c1"));
51  Assert.IsTrue(exists);
52  }
53  }
54 }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
override ISession CreateAdminSession(IDatabase database)
Definition: CursorTests.cs:27
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Definition: ObjectName.cs:139
Describes the name of an object within a database.
Definition: ObjectName.cs:44
The representation of a single database in the system.
Definition: IDatabase.cs:40
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
A container for the FROM clause of a select statement.
Definition: FromClause.cs:32
An isolated session to a given database for a given user, encapsulating the transaction for operation...
Definition: ISession.cs:30
Represents a column selected to be in the output of a select statement.
Definition: SelectColumn.cs:31
Defines the base class for instances that represent SQL expression tree nodes.
static SqlConstantExpression Constant(object value)
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41