DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ConstantVisitor.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 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 //
16 
17 using System;
18 
19 using Deveel.Data.Sql.Objects;
20 using Deveel.Data.Types;
21 
22 namespace Deveel.Data.Sql.Expressions {
24  public ConstantVisitor() {
25  IsConstant = true;
26  }
27 
28  public bool IsConstant { get; private set; }
29 
31  var value = constant.Value;
32  if (value.Type.TypeCode == SqlTypeCode.Array) {
33  var array = value.Value as SqlArray;
34  if (array != null && !array.IsNull) {
35  foreach (var exp in array) {
36  if (!exp.IsConstant()) {
37  IsConstant = false;
38  break;
39  }
40  }
41  }
42  }
43 
44  return base.VisitConstant(constant);
45  }
46 
48  IsConstant = false;
49  return base.VisitReference(reference);
50  }
51 
53  IsConstant = false;
54  return base.VisitVariableReference(reference);
55  }
56 
58  return base.VisitFunctionCall(expression);
59  }
60 
61  public override SqlExpression VisitQuery(SqlQueryExpression query) {
62  return base.VisitQuery(query);
63  }
64  }
65 }
override SqlExpression VisitVariableReference(SqlVariableReferenceExpression reference)
An expression that references an object within a context.
ISqlObject Value
Gets the underlined value that is handled.
Definition: DataObject.cs:84
DataObject Value
Gets the constant value of the expression.
override SqlExpression VisitConstant(SqlConstantExpression constant)
override SqlExpression VisitFunctionCall(SqlFunctionCallExpression expression)
Visits the expression that calls the function defined.
override SqlExpression VisitQuery(SqlQueryExpression query)
override SqlExpression VisitReference(SqlReferenceExpression reference)
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
An expression that holds a constant value.
Defines the base class for instances that represent SQL expression tree nodes.
An object that provides methods for accessing a finite collection of SQL expressions.
Definition: SqlArray.cs:28