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

Static Public Member Functions

static DataObject Or (DataObject ob1, DataObject ob2)
 
static DataObject User (IRequest query)
 
static DataObject ToDate (DataObject obj)
 
static DataObject ToDate (SqlString value)
 
static DataObject ToDateTime (DataObject obj)
 
static DataObject ToDateTime (SqlString value)
 
static DataObject ToTimeStamp (DataObject obj)
 
static DataObject ToTimeStamp (SqlString value)
 
static DataObject Cast (DataObject value, SqlType destType)
 
static DataObject Cast (IQuery query, DataObject value, SqlString typeString)
 
static DataObject ToNumber (DataObject value)
 
static DataObject ToString (DataObject value)
 
static DataObject ToBinary (DataObject value)
 
static DataObject UniqueKey (IRequest query, DataObject tableName)
 
static SqlNumber UniqueKey (IRequest query, SqlString tableName)
 
static DataObject CurrentValue (IRequest query, DataObject tableName)
 
static SqlNumber CurrentValue (IRequest query, SqlString tableName)
 

Static Package Functions

static InvokeResult Iif (InvokeContext context)
 
static DataObject FRuleConvert (DataObject obj)
 

Properties

static FunctionProvider Provider [get, private set]
 

Static Private Member Functions

static SystemFunctions ()
 

Detailed Description

Definition at line 28 of file SystemFunctions.cs.

Constructor & Destructor Documentation

static Deveel.Data.Routines.SystemFunctions.SystemFunctions ( )
inlinestaticprivate

Definition at line 29 of file SystemFunctions.cs.

29  {
30  Provider = new SystemFunctionsProvider();
31  }
static FunctionProvider Provider

Member Function Documentation

static DataObject Deveel.Data.Routines.SystemFunctions.Cast ( DataObject  value,
SqlType  destType 
)
inlinestatic

Definition at line 68 of file SystemFunctions.cs.

68  {
69  return value.CastTo(destType);
70  }
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static DataObject Deveel.Data.Routines.SystemFunctions.Cast ( IQuery  query,
DataObject  value,
SqlString  typeString 
)
inlinestatic

Definition at line 72 of file SystemFunctions.cs.

72  {
73  var destType = SqlType.Parse(query.Context, typeString.ToString());
74  return Cast(value, destType);
75  }
static DataObject Cast(DataObject value, SqlType destType)
string ToString(Encoding encoding)
Definition: SqlString.cs:182
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
new IQueryContext Context
Definition: IQuery.cs:21
static SqlType Parse(string s)
Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent...
Definition: SqlType.cs:321
static DataObject Deveel.Data.Routines.SystemFunctions.CurrentValue ( IRequest  query,
DataObject  tableName 
)
inlinestatic

Definition at line 101 of file SystemFunctions.cs.

101  {
102  var tableNameString = (SqlString)tableName.Value;
103  var value = CurrentValue(query, tableNameString);
104  return DataObject.Number(value);
105  }
static DataObject Number(SqlNumber value)
Definition: DataObject.cs:552
static DataObject CurrentValue(IRequest query, DataObject tableName)
ISqlObject Value
Gets the underlined value that is handled.
Definition: DataObject.cs:84
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
static SqlNumber Deveel.Data.Routines.SystemFunctions.CurrentValue ( IRequest  query,
SqlString  tableName 
)
inlinestatic

Definition at line 107 of file SystemFunctions.cs.

107  {
108  var tableNameString = tableName.ToString();
109  var resolvedName = query.Query.ResolveTableName(tableNameString);
110  return query.Query.GetCurrentValue(resolvedName);
111  }
string ToString(Encoding encoding)
Definition: SqlString.cs:182
static DataObject Deveel.Data.Routines.SystemFunctions.FRuleConvert ( DataObject  obj)
inlinestaticpackage

Definition at line 130 of file SystemFunctions.cs.

130  {
131  if (obj.Type is StringType) {
132  String str = null;
133  if (!obj.IsNull) {
134  str = obj.Value.ToString();
135  }
136  int v;
137  if (str == null || str.Equals("") || str.Equals("NO ACTION")) {
138  v = ImportedKey.NoAction;
139  } else if (str.Equals("CASCADE")) {
140  v = ImportedKey.Cascade;
141  } else if (str.Equals("SET NULL")) {
142  v = ImportedKey.SetNull;
143  } else if (str.Equals("SET DEFAULT")) {
144  v = ImportedKey.SetDefault;
145  } else if (str.Equals("RESTRICT")) {
146  v = ImportedKey.Restrict;
147  } else {
148  throw new InvalidOperationException("Unrecognised foreign key rule: " + str);
149  }
150 
151  // Return the correct enumeration
152  return DataObject.Integer(v);
153  }
154  if (obj.Type is NumericType) {
155  var code = ((SqlNumber)obj.AsBigInt().Value).ToInt32();
156  string v;
157  if (code == (int)ForeignKeyAction.Cascade) {
158  v = "CASCADE";
159  } else if (code == (int)ForeignKeyAction.NoAction) {
160  v = "NO ACTION";
161  } else if (code == (int)ForeignKeyAction.SetDefault) {
162  v = "SET DEFAULT";
163  } else if (code == (int)ForeignKeyAction.SetNull) {
164  v = "SET NULL";
165  } else {
166  throw new InvalidOperationException("Unrecognised foreign key rule: " + code);
167  }
168 
169  return DataObject.String(v);
170  }
171 
172  throw new InvalidOperationException("Unsupported type in function argument");
173  }
bool IsNull
Gets a value that indicates if this object is materialized as null.
Definition: DataObject.cs:91
static DataObject Integer(int value)
Definition: DataObject.cs:576
SqlType Type
Gets the SqlType that defines the object properties
Definition: DataObject.cs:78
A long string in the system.
ISqlObject Value
Gets the underlined value that is handled.
Definition: DataObject.cs:84
static DataObject String(string s)
Definition: DataObject.cs:592
DataObject AsBigInt()
Definition: DataObject.cs:524
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
static InvokeResult Deveel.Data.Routines.SystemFunctions.Iif ( InvokeContext  context)
inlinestaticpackage

Definition at line 113 of file SystemFunctions.cs.

113  {
114  var result = DataObject.Null();
115 
116  var evalContext = new EvaluateContext(context.Request, context.VariableResolver, context.GroupResolver);
117 
118  var condition = context.Arguments[0].EvaluateToConstant(evalContext);
119  if (condition.Type is BooleanType) {
120  if (condition.Equals(DataObject.BooleanTrue)) {
121  result = context.Arguments[1].EvaluateToConstant(evalContext);
122  } else if (condition.Equals(DataObject.BooleanFalse)) {
123  result = context.Arguments[2].EvaluateToConstant(evalContext);
124  }
125  }
126 
127  return context.Result(result);
128  }
static readonly DataObject BooleanFalse
The representation of a BOOLEAN false as DataObject
Definition: DataObject.cs:44
static DataObject Null(SqlType type)
Definition: DataObject.cs:630
static readonly DataObject BooleanTrue
The representation of a BOOLEAN true as DataObject
Definition: DataObject.cs:39
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
Encapsulates the elements needed to evaluate an SqlExpression
static DataObject Deveel.Data.Routines.SystemFunctions.Or ( DataObject  ob1,
DataObject  ob2 
)
inlinestatic

Definition at line 35 of file SystemFunctions.cs.

35  {
36  return ob1 != null ? (ob2.IsNull ? ob1 : (!ob1.IsNull ? ob1.Or(ob2) : ob2)) : ob2;
37  }
bool IsNull
Gets a value that indicates if this object is materialized as null.
Definition: DataObject.cs:91
DataObject Or(DataObject other)
Definition: DataObject.cs:428
static DataObject Deveel.Data.Routines.SystemFunctions.ToBinary ( DataObject  value)
inlinestatic

Definition at line 85 of file SystemFunctions.cs.

85  {
86  return value.CastTo(PrimitiveTypes.Binary());
87  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static BinaryType Binary(int maxSize)
static DataObject Deveel.Data.Routines.SystemFunctions.ToDate ( DataObject  obj)
inlinestatic

Definition at line 44 of file SystemFunctions.cs.

44  {
45  return obj.CastTo(PrimitiveTypes.Date());
46  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static DataObject Deveel.Data.Routines.SystemFunctions.ToDate ( SqlString  value)
inlinestatic

Definition at line 48 of file SystemFunctions.cs.

48  {
49  return ToDate(DataObject.String(value));
50  }
static DataObject ToDate(DataObject obj)
static DataObject String(string s)
Definition: DataObject.cs:592
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
static DataObject Deveel.Data.Routines.SystemFunctions.ToDateTime ( DataObject  obj)
inlinestatic

Definition at line 52 of file SystemFunctions.cs.

52  {
53  return obj.CastTo(PrimitiveTypes.DateTime());
54  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static DataObject Deveel.Data.Routines.SystemFunctions.ToDateTime ( SqlString  value)
inlinestatic

Definition at line 56 of file SystemFunctions.cs.

56  {
57  return ToDateTime(DataObject.String(value));
58  }
static DataObject String(string s)
Definition: DataObject.cs:592
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
static DataObject ToDateTime(DataObject obj)
static DataObject Deveel.Data.Routines.SystemFunctions.ToNumber ( DataObject  value)
inlinestatic

Definition at line 77 of file SystemFunctions.cs.

77  {
78  return value.CastTo(PrimitiveTypes.Numeric());
79  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static NumericType Numeric()
static DataObject Deveel.Data.Routines.SystemFunctions.ToString ( DataObject  value)
inlinestatic

Definition at line 81 of file SystemFunctions.cs.

81  {
82  return value.CastTo(PrimitiveTypes.String());
83  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static DataObject Deveel.Data.Routines.SystemFunctions.ToTimeStamp ( DataObject  obj)
inlinestatic

Definition at line 60 of file SystemFunctions.cs.

60  {
61  return obj.CastTo(PrimitiveTypes.TimeStamp());
62  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
DataObject CastTo(SqlType destType)
Converts this object to the given SqlType.
Definition: DataObject.cs:488
static DataObject Deveel.Data.Routines.SystemFunctions.ToTimeStamp ( SqlString  value)
inlinestatic

Definition at line 64 of file SystemFunctions.cs.

64  {
65  return ToTimeStamp(DataObject.String(value));
66  }
static DataObject String(string s)
Definition: DataObject.cs:592
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
static DataObject ToTimeStamp(DataObject obj)
static DataObject Deveel.Data.Routines.SystemFunctions.UniqueKey ( IRequest  query,
DataObject  tableName 
)
inlinestatic

Definition at line 89 of file SystemFunctions.cs.

89  {
90  var tableNameString = (SqlString)tableName.Value;
91  var value = UniqueKey(query, tableNameString);
92  return DataObject.Number(value);
93  }
static DataObject Number(SqlNumber value)
Definition: DataObject.cs:552
static DataObject UniqueKey(IRequest query, DataObject tableName)
ISqlObject Value
Gets the underlined value that is handled.
Definition: DataObject.cs:84
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
static SqlNumber Deveel.Data.Routines.SystemFunctions.UniqueKey ( IRequest  query,
SqlString  tableName 
)
inlinestatic

Definition at line 95 of file SystemFunctions.cs.

95  {
96  var tableNameString = tableName.ToString();
97  var resolvedName = query.Query.ResolveTableName(tableNameString);
98  return query.Query.GetNextValue(resolvedName);
99  }
string ToString(Encoding encoding)
Definition: SqlString.cs:182
static DataObject Deveel.Data.Routines.SystemFunctions.User ( IRequest  query)
inlinestatic

Definition at line 39 of file SystemFunctions.cs.

39  {
40  return DataObject.String(query.User().Name);
41  }
static DataObject String(string s)
Definition: DataObject.cs:592
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35

Property Documentation

FunctionProvider Deveel.Data.Routines.SystemFunctions.Provider
staticgetprivate set

Definition at line 33 of file SystemFunctions.cs.


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