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.Expressions.SqlExpressionVisitor Class Reference

A visitor for SqlExpression objects. More...

Inheritance diagram for Deveel.Data.Sql.Expressions.SqlExpressionVisitor:
Deveel.Data.Sql.Expressions.AggregateChecker Deveel.Data.Sql.Expressions.ConstantVisitor Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor Deveel.Data.Sql.Expressions.ExpressionStringBuilder Deveel.Data.Sql.Expressions.PreparerVisitor Deveel.Data.Sql.Expressions.ReturnTypeVisitor Deveel.Data.Sql.Query.ExpressionReferenceExplorer.ReferenceDiscover Deveel.Data.Sql.Query.QueryExpressionExtensions.ReferenceDiscovery Deveel.Data.Sql.Query.QueryExpressionExtensions.SubQueryDiscovery Deveel.Data.Sql.Query.QueryPlanner.VariableReplacer Deveel.Data.Sql.Query.QueryReferencesVisitor Deveel.Data.Sql.Query.RangeSelectNode.RangeSetCalculator Deveel.Data.Sql.Query.RangeSelectNode.RangeSetUpdater Deveel.Data.Sql.Query.TableNamesVisitor Deveel.Data.Sql.Statements.ColumnChecker.ExpressionChecker Deveel.Data.Sql.Tables.TableInfo.ColumnsResolver

Public Member Functions

virtual SqlExpression Visit (SqlExpression expression)
 Visits a given SQL expression. More...
 
virtual SqlExpression[] VisitExpressionList (SqlExpression[] list)
 Visits a list of expressions given. More...
 
virtual SqlExpression VisitFunctionCall (SqlFunctionCallExpression expression)
 Visits the expression that calls the function defined. More...
 
virtual SqlExpression VisitBinary (SqlBinaryExpression binaryEpression)
 
virtual SqlExpression VisitUnary (SqlUnaryExpression unary)
 
virtual SqlExpression VisitCast (SqlCastExpression castExpression)
 
virtual SqlExpression VisitReference (SqlReferenceExpression reference)
 
virtual SqlExpression VisitVariableReference (SqlVariableReferenceExpression reference)
 
virtual SqlExpression VisitAssign (SqlAssignExpression assign)
 
virtual SqlExpression VisitConstant (SqlConstantExpression constant)
 
virtual SqlExpression VisitConditional (SqlConditionalExpression conditional)
 
virtual SqlExpression VisitTuple (SqlTupleExpression expression)
 
virtual SqlExpression VisitQuery (SqlQueryExpression query)
 

Private Member Functions

FromClause VisitFromClause (FromClause fromClause)
 

Detailed Description

A visitor for SqlExpression objects.

Definition at line 25 of file SqlExpressionVisitor.cs.

Member Function Documentation

virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.Visit ( SqlExpression  expression)
inlinevirtual

Visits a given SQL expression.

Parameters
expressionThe SqlExpression to visit.
Returns
Returns an instance of SqlExpression as result of the visit.

Reimplemented in Deveel.Data.Sql.Expressions.ReturnTypeVisitor, Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, Deveel.Data.Sql.Query.QueryReferencesVisitor, and Deveel.Data.Sql.Expressions.PreparerVisitor.

Definition at line 33 of file SqlExpressionVisitor.cs.

33  {
34  if (expression == null)
35  return null;
36 
37  var expressionType = expression.ExpressionType;
38  switch (expressionType) {
39  case SqlExpressionType.Add:
40  case SqlExpressionType.Subtract:
41  case SqlExpressionType.Divide:
42  case SqlExpressionType.Multiply:
43  case SqlExpressionType.Modulo:
44  case SqlExpressionType.And:
45  case SqlExpressionType.Or:
46  case SqlExpressionType.XOr:
47  case SqlExpressionType.Equal:
48  case SqlExpressionType.NotEqual:
49  case SqlExpressionType.Like:
50  case SqlExpressionType.NotLike:
51  case SqlExpressionType.GreaterThan:
52  case SqlExpressionType.GreaterOrEqualThan:
53  case SqlExpressionType.SmallerThan:
54  case SqlExpressionType.SmallerOrEqualThan:
55  case SqlExpressionType.Is:
56  case SqlExpressionType.IsNot:
57  case SqlExpressionType.AllEqual:
58  case SqlExpressionType.AllNotEqual:
59  case SqlExpressionType.AllGreaterThan:
60  case SqlExpressionType.AllSmallerThan:
61  case SqlExpressionType.AllGreaterOrEqualThan:
62  case SqlExpressionType.AllSmallerOrEqualThan:
63  case SqlExpressionType.AnyEqual:
64  case SqlExpressionType.AnyNotEqual:
65  case SqlExpressionType.AnyGreaterThan:
66  case SqlExpressionType.AnySmallerThan:
67  case SqlExpressionType.AnyGreaterOrEqualThan:
68  case SqlExpressionType.AnySmallerOrEqualThan:
69  return VisitBinary((SqlBinaryExpression) expression);
70  case SqlExpressionType.Negate:
71  case SqlExpressionType.Not:
72  case SqlExpressionType.UnaryPlus:
73  return VisitUnary((SqlUnaryExpression) expression);
74  case SqlExpressionType.Cast:
75  return VisitCast((SqlCastExpression) expression);
76  case SqlExpressionType.Reference:
77  return VisitReference((SqlReferenceExpression) expression);
78  case SqlExpressionType.VariableReference:
79  return VisitVariableReference((SqlVariableReferenceExpression) expression);
80  case SqlExpressionType.Assign:
81  return VisitAssign((SqlAssignExpression) expression);
82  case SqlExpressionType.FunctionCall:
83  return VisitFunctionCall((SqlFunctionCallExpression) expression);
84  case SqlExpressionType.Constant:
85  return VisitConstant((SqlConstantExpression) expression);
86  case SqlExpressionType.Conditional:
87  return VisitConditional((SqlConditionalExpression) expression);
88  case SqlExpressionType.Query:
89  return VisitQuery((SqlQueryExpression) expression);
90  case SqlExpressionType.Tuple:
91  return VisitTuple((SqlTupleExpression) expression);
92  default:
93  return expression.Accept(this);
94  }
95  }
virtual SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
Visits the expression that calls the function defined.
virtual SqlExpression VisitUnary(SqlUnaryExpression unary)
virtual SqlExpression VisitTuple(SqlTupleExpression expression)
SqlExpressionType
All the possible type of SqlExpression supported
virtual SqlExpression VisitQuery(SqlQueryExpression query)
virtual SqlExpression VisitBinary(SqlBinaryExpression binaryEpression)
virtual SqlExpression VisitCast(SqlCastExpression castExpression)
virtual SqlExpression VisitReference(SqlReferenceExpression reference)
virtual SqlExpression VisitConditional(SqlConditionalExpression conditional)
virtual SqlExpression VisitConstant(SqlConstantExpression constant)
virtual SqlExpression VisitVariableReference(SqlVariableReferenceExpression reference)
virtual SqlExpression VisitAssign(SqlAssignExpression assign)
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitAssign ( SqlAssignExpression  assign)
inlinevirtual

Parameters
assign
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, Deveel.Data.Sql.Expressions.ExpressionStringBuilder, and Deveel.Data.Sql.Expressions.PreparerVisitor.

Definition at line 188 of file SqlExpressionVisitor.cs.

188  {
189  var reference = assign.ReferenceExpression;
190  if (reference != null)
191  reference = Visit(reference);
192 
193  var expression = assign.ValueExpression;
194  if (expression != null)
195  expression = Visit(expression);
196 
197  return SqlExpression.Assign(reference, expression);
198  }
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitBinary ( SqlBinaryExpression  binaryEpression)
inlinevirtual

Parameters
binaryEpression
Returns

Reimplemented in Deveel.Data.Sql.Query.RangeSelectNode.RangeSetCalculator, Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, Deveel.Data.Sql.Query.RangeSelectNode.RangeSetUpdater, Deveel.Data.Sql.Expressions.ExpressionStringBuilder, and Deveel.Data.Sql.Expressions.ReturnTypeVisitor.

Definition at line 136 of file SqlExpressionVisitor.cs.

136  {
137  var left = binaryEpression.Left;
138  var right = binaryEpression.Right;
139  if (left != null)
140  left = Visit(left);
141  if (right != null)
142  right = Visit(right);
143 
144  return SqlExpression.Binary(left, binaryEpression.ExpressionType, right);
145  }
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitCast ( SqlCastExpression  castExpression)
inlinevirtual

Parameters
castExpression
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, and Deveel.Data.Sql.Expressions.ExpressionStringBuilder.

Definition at line 165 of file SqlExpressionVisitor.cs.

165  {
166  // TODO:
167  return castExpression;
168  }
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitConditional ( SqlConditionalExpression  conditional)
inlinevirtual

Parameters
conditional
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, and Deveel.Data.Sql.Expressions.ExpressionStringBuilder.

Definition at line 214 of file SqlExpressionVisitor.cs.

214  {
215  var test = conditional.TestExpression;
216  var ifTrue = conditional.TrueExpression;
217  var ifFalse = conditional.FalseExpression;
218 
219  if (test != null)
220  test = Visit(test);
221  if (ifTrue != null)
222  ifTrue = Visit(ifTrue);
223  if (ifFalse != null)
224  ifFalse = Visit(ifFalse);
225 
226  return SqlExpression.Conditional(test, ifTrue, ifFalse);
227  }
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitConstant ( SqlConstantExpression  constant)
inlinevirtual
virtual SqlExpression [] Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitExpressionList ( SqlExpression[]  list)
inlinevirtual

Visits a list of expressions given.

Parameters
listThe list of SqlExpression to visit.

The default implementation iterates the given list and visits any expression contained.

Returns
Returns a new array of SqlExpression resulted from the visit to each of the input expressions.

Definition at line 109 of file SqlExpressionVisitor.cs.

109  {
110  if (list == null)
111  return new SqlExpression[0];
112 
113  var result = new SqlExpression[list.Length];
114  for (int i = 0; i < list.Length; i++) {
115  result[i] = Visit(list[i]);
116  }
117 
118  return result;
119  }
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
FromClause Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitFromClause ( FromClause  fromClause)
inlineprivate

Definition at line 284 of file SqlExpressionVisitor.cs.

284  {
285  // TODO:
286  return fromClause;
287  }
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitFunctionCall ( SqlFunctionCallExpression  expression)
inlinevirtual

Visits the expression that calls the function defined.

Parameters
expressionThe SqlFunctionCallExpression to visit.
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, Deveel.Data.Sql.Expressions.ExpressionStringBuilder, Deveel.Data.Sql.Query.QueryExpressionExtensions.ReferenceDiscovery, Deveel.Data.Sql.Expressions.ReturnTypeVisitor, Deveel.Data.Sql.Expressions.ConstantVisitor, and Deveel.Data.Sql.Expressions.AggregateChecker.

Definition at line 126 of file SqlExpressionVisitor.cs.

126  {
127  var ags = VisitExpressionList(expression.Arguments);
128  return SqlExpression.FunctionCall(expression.FunctioName, ags);
129  }
virtual SqlExpression[] VisitExpressionList(SqlExpression[] list)
Visits a list of expressions given.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitQuery ( SqlQueryExpression  query)
inlinevirtual

Parameters
query
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionStringBuilder, Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor, Deveel.Data.Sql.Statements.ColumnChecker.ExpressionChecker, Deveel.Data.Sql.Expressions.PreparerVisitor, and Deveel.Data.Sql.Expressions.ConstantVisitor.

Definition at line 247 of file SqlExpressionVisitor.cs.

247  {
248  var selectColumns = new List<SelectColumn>();
249  foreach (var column in query.SelectColumns) {
250  var newColumn = new SelectColumn(Visit(column.Expression), column.Alias);
251  newColumn.InternalName = column.InternalName;
252  newColumn.ResolvedName = column.ResolvedName;
253  selectColumns.Add(newColumn);
254  }
255 
256  var newQuery = new SqlQueryExpression(selectColumns);
257 
258  if (query.FromClause != null)
259  newQuery.FromClause = VisitFromClause(query.FromClause);
260 
261  if (query.WhereExpression != null)
262  newQuery.WhereExpression = Visit(query.WhereExpression);
263  if (query.HavingExpression != null)
264  newQuery.HavingExpression = Visit(query.HavingExpression);
265 
266  if (query.GroupBy != null)
267  newQuery.GroupBy = VisitExpressionList(newQuery.GroupBy.ToArray());
268 
269  newQuery.GroupMax = query.GroupMax;
270  newQuery.Distinct = query.Distinct;
271 
272  if (query.NextComposite != null) {
273  var visitedComposite = Visit(query.NextComposite);
274  if (visitedComposite.ExpressionType == SqlExpressionType.Query)
275  newQuery.NextComposite = (SqlQueryExpression) visitedComposite;
276 
277  newQuery.CompositeFunction = query.CompositeFunction;
278  newQuery.IsCompositeAll = query.IsCompositeAll;
279  }
280 
281  return query;
282  }
FromClause VisitFromClause(FromClause fromClause)
SqlExpressionType
All the possible type of SqlExpression supported
virtual SqlExpression[] VisitExpressionList(SqlExpression[] list)
Visits a list of expressions given.
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitReference ( SqlReferenceExpression  reference)
inlinevirtual
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitTuple ( SqlTupleExpression  expression)
inlinevirtual

Parameters
expression
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionStringBuilder, and Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor.

Definition at line 234 of file SqlExpressionVisitor.cs.

234  {
235  var list = expression.Expressions;
236  if (list != null)
237  list = VisitExpressionList(list);
238 
239  return SqlExpression.Tuple(list);
240  }
virtual SqlExpression[] VisitExpressionList(SqlExpression[] list)
Visits a list of expressions given.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitUnary ( SqlUnaryExpression  unary)
inlinevirtual

Parameters
unary
Returns

Reimplemented in Deveel.Data.Sql.Expressions.ExpressionStringBuilder, and Deveel.Data.Sql.Expressions.ExpressionEvaluatorVisitor.

Definition at line 152 of file SqlExpressionVisitor.cs.

152  {
153  var operand = unary.Operand;
154  if (operand != null)
155  operand = Visit(operand);
156 
157  return SqlExpression.Unary(unary.ExpressionType, operand);
158  }
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
virtual SqlExpression Deveel.Data.Sql.Expressions.SqlExpressionVisitor.VisitVariableReference ( SqlVariableReferenceExpression  reference)
inlinevirtual

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