DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | Static Package Functions | List of all members
Deveel.Data.Sql.QueryContextExtensions Class Reference

Static Public Member Functions

static bool ObjectExists (this IQueryContext context, ObjectName objectName)
 
static bool ObjectExists (this IQueryContext context, DbObjectType objectType, ObjectName objectName)
 
static IDbObject GetObject (this IQueryContext context, DbObjectType objType, ObjectName objName)
 
static IDbObject GetObject (this IQueryContext context, DbObjectType objType, ObjectName objName, AccessType accessType)
 
static bool DropObject (this IQueryContext context, DbObjectType objectType, ObjectName objectName)
 
static void AlterObject (this IQueryContext context, IObjectInfo objectInfo)
 
static ObjectName ResolveObjectName (this IQueryContext context, string name)
 
static ObjectName ResolveObjectName (this IQueryContext context, DbObjectType objectType, ObjectName objectName)
 
static IDbObject FindObject (this IQueryContext context, ObjectName objectName)
 

Static Package Functions

static void CreateObject (this IQueryContext context, IObjectInfo objectInfo)
 

Detailed Description

Definition at line 9 of file QueryContext.Objects.cs.

Member Function Documentation

static void Deveel.Data.Sql.QueryContextExtensions.AlterObject ( this IQueryContext  context,
IObjectInfo  objectInfo 
)
inlinestatic

Definition at line 90 of file QueryContext.Objects.cs.

90  {
91  if (objectInfo == null)
92  throw new ArgumentNullException("objectInfo");
93 
94  if (!context.UserCanAlterObject(objectInfo.ObjectType, objectInfo.FullName))
95  throw new MissingPrivilegesException(context.UserName(), objectInfo.FullName, Privileges.Alter);
96 
97  context.Session().AlterObject(objectInfo);
98  }
static void Deveel.Data.Sql.QueryContextExtensions.CreateObject ( this IQueryContext  context,
IObjectInfo  objectInfo 
)
inlinestaticpackage

Definition at line 65 of file QueryContext.Objects.cs.

65  {
66  // TODO: throw a specialized exception
67  if (!context.UserCanCreateObject(objectInfo.ObjectType, objectInfo.FullName))
68  throw new InvalidOperationException();
69 
70  context.Session().CreateObject(objectInfo);
71  }
static bool Deveel.Data.Sql.QueryContextExtensions.DropObject ( this IQueryContext  context,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 73 of file QueryContext.Objects.cs.

73  {
74  if (objectType == DbObjectType.Variable &&
75  context.DropVariable(objectName.Name)) {
76  return true;
77  }
78  if (objectType == DbObjectType.Cursor &&
79  context.DropCursor(objectName.Name)) {
80  return true;
81  }
82 
83  if (!context.UserCanDropObject(objectType, objectName))
84  throw new MissingPrivilegesException(context.UserName(), objectName, Privileges.Drop);
85 
86  context.Session().DropObject(objectType, objectName);
87  return true;
88  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static IDbObject Deveel.Data.Sql.QueryContextExtensions.FindObject ( this IQueryContext  context,
ObjectName  objectName 
)
inlinestatic

Definition at line 119 of file QueryContext.Objects.cs.

119  {
120  return context.Session().FindObject(objectName);
121  }
static IDbObject Deveel.Data.Sql.QueryContextExtensions.GetObject ( this IQueryContext  context,
DbObjectType  objType,
ObjectName  objName 
)
inlinestatic

Definition at line 39 of file QueryContext.Objects.cs.

39  {
40  return GetObject(context, objType, objName, AccessType.ReadWrite);
41  }
static IDbObject GetObject(this IQueryContext context, DbObjectType objType, ObjectName objName)
static IDbObject Deveel.Data.Sql.QueryContextExtensions.GetObject ( this IQueryContext  context,
DbObjectType  objType,
ObjectName  objName,
AccessType  accessType 
)
inlinestatic

Definition at line 43 of file QueryContext.Objects.cs.

43  {
44  // First handle the special cases of cursors and variable, that can be declared
45  // in a query context
46  // If they are declared in the context, the user owns them and we don't need
47  // to verify the ownership
48  if (objType == DbObjectType.Cursor) {
49  var obj = context.FindCursor(objName.Name);
50  if (obj != null)
51  return obj;
52  } else if (objType == DbObjectType.Variable) {
53  var obj = context.FindVariable(objName.Name);
54  if (obj != null)
55  return obj;
56  }
57 
58  // TODO: throw a specialized exception
59  if (!context.UserCanAccessObject(objType, objName))
60  throw new InvalidOperationException();
61 
62  return context.Session().GetObject(objType, objName, accessType);
63  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static bool Deveel.Data.Sql.QueryContextExtensions.ObjectExists ( this IQueryContext  context,
ObjectName  objectName 
)
inlinestatic

Definition at line 10 of file QueryContext.Objects.cs.

10  {
11  // Special types for these database objects that can be
12  // declared in a limited context
13  if (context.CursorExists(objectName.Name))
14  return true;
15  if (context.VariableExists(objectName.Name))
16  return true;
17 
18  // We haven't found it neither in this context nor in the parent:
19  // fallback to the transaction scope
20  return context.Session().ObjectExists(objectName);
21  }
static bool Deveel.Data.Sql.QueryContextExtensions.ObjectExists ( this IQueryContext  context,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 23 of file QueryContext.Objects.cs.

23  {
24  // Special types for these database objects that can be
25  // declared in a limited context
26  if (objectType == DbObjectType.Cursor &&
27  context.CursorExists(objectName.Name))
28  return true;
29 
30  if (objectType == DbObjectType.Variable &&
31  context.VariableExists(objectName.Name))
32  return true;
33 
34  // We haven't found it neither in this context nor in the parent:
35  // fallback to the transaction scope
36  return context.Session().ObjectExists(objectType, objectName);
37  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static ObjectName Deveel.Data.Sql.QueryContextExtensions.ResolveObjectName ( this IQueryContext  context,
string  name 
)
inlinestatic

Definition at line 100 of file QueryContext.Objects.cs.

100  {
101  if (context.VariableExists(name) ||
102  context.CursorExists(name))
103  return new ObjectName(name);
104 
105  return context.Session().ResolveObjectName(name);
106  }
static ObjectName Deveel.Data.Sql.QueryContextExtensions.ResolveObjectName ( this IQueryContext  context,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 108 of file QueryContext.Objects.cs.

108  {
109  if (objectType == DbObjectType.Variable &&
110  context.VariableExists(objectName.Name))
111  return new ObjectName(objectName.Name);
112  if (objectType == DbObjectType.Cursor &&
113  context.CursorExists(objectName.Name))
114  return new ObjectName(objectName.Name);
115 
116  return context.Session().ResolveObjectName(objectType, objectName);
117  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27

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