25 namespace Deveel.Data.Sql.Expressions {
58 public virtual bool CanEvaluate {
62 internal int EvaluatePrecedence {
129 set { precedence = value; }
134 return visitor.Visit(
this);
138 return visitor.
Visit(
this);
169 return visitor.Visit(
this);
195 return Evaluate(null, null);
199 return Evaluate(context, variables, null);
208 return builder.ToSqlString(
this);
220 return Parse(s, null);
236 var result = compiler.
Parse(s);
238 if (result.HasErrors)
248 "Could not parse input expression: see inner exception for details.", ex);
252 #region Factory Methods
302 #region Binary Expressions
306 return Add(left, right);
312 return Divide(left, right);
314 return Modulo(left, right);
317 return Equal(left, right);
321 return Is(left, right);
323 return IsNot(left, right);
334 return Like(left, right);
339 return And(left, right);
341 return Or(left, right);
343 return XOr(left, right);
345 if (expressionType.IsAny())
346 return Any(left, expressionType.SubQueryPlainType(), right);
347 if (expressionType.IsAll())
348 return All(left, expressionType.SubQueryPlainType(), right);
350 throw new ArgumentException(
String.Format(
"Expression type {0} is not a Binary", expressionType));
445 throw new ArgumentException(
String.Format(
"The type '{0}' cannot be part of an ANY operator.", anyType));
492 throw new ArgumentException(
String.Format(
"The type '{0}' cannot be part of an ALL operator.", allType));
521 #region Unary Expressions
531 throw new ArgumentException(
String.Format(
"Expression Type {0} is not an Unary.", expressionType));
558 return Tuple(
new[] {expr1, exp2});
562 return Tuple(
new[] {expr1, expr2, expr3});
569 serializer.Serialize(writer, expression);
static SqlBinaryExpression Divide(SqlExpression left, SqlExpression right)
void GetData(SerializeData data)
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
static SqlBinaryExpression AllGreaterThan(SqlExpression left, SqlExpression right)
static SqlExpression Parse(string s)
Parses the given SQL string to an expression that can be evaluated.
An expression that references an object within a context.
static SqlBinaryExpression All(SqlExpression left, SqlExpressionType allType, SqlExpression right)
A long string in the system.
static SqlBinaryExpression And(SqlExpression left, SqlExpression right)
Handles expressions computed against an unary operator.
static SqlBinaryExpression SmallerOrEqualThan(SqlExpression left, SqlExpression right)
static SqlBinaryExpression AllSmallerThan(SqlExpression left, SqlExpression right)
The execution context of a database system, that is defining the configurations and the components us...
static SqlBinaryExpression Multiply(SqlExpression left, SqlExpression right)
static SqlBinaryExpression AllGreaterOrEqualThan(SqlExpression left, SqlExpression right)
virtual void GetData(SerializeData data)
static SqlExpression Build(IExpressionNode node)
static DataObject Create(object value)
static SqlTupleExpression Tuple(SqlExpression[] expressions)
An SqlExpression that will cast a value retrieved by the evaluation of another expression into a give...
static SqlVariableReferenceExpression VariableReference(string varName)
static SqlBinaryExpression Equal(SqlExpression left, SqlExpression right)
static SqlBinaryExpression SmallerThan(SqlExpression left, SqlExpression right)
Describes the name of an object within a database.
static SqlBinaryExpression AnySmallerThan(SqlExpression left, SqlExpression right)
static SqlTupleExpression Tuple(SqlExpression expr1, SqlExpression expr2, SqlExpression expr3)
static SqlAssignExpression Assign(SqlExpression reference, SqlExpression valueExpression)
SqlExpression()
Internally constructs the SQL expression, avoiding external implementations to be allowed to inherit ...
static SqlUnaryExpression Not(SqlExpression operand)
static SqlConditionalExpression Conditional(SqlExpression testExpression, SqlExpression ifTrue)
static void Serialize(SqlExpression expression, BinaryWriter writer)
SqlExpressionType
All the possible type of SqlExpression supported
SqlExpression(ObjectData data)
SqlExpression Evaluate(IRequest context, IVariableResolver variables)
virtual SqlExpression Evaluate(EvaluateContext context)
When overridden by a derived class, this method evaluates the expression within the provided context...
static SqlBinaryExpression AllSmallerOrEqualThan(SqlExpression left, SqlExpression right)
static SqlConstantExpression Constant(DataObject value)
static SqlBinaryExpression Modulo(SqlExpression left, SqlExpression right)
static SqlBinaryExpression Add(SqlExpression left, SqlExpression right)
static SqlBinaryExpression Or(SqlExpression left, SqlExpression right)
static SqlBinaryExpression IsNot(SqlExpression left, SqlExpression right)
static SqlExpression Deserialize(BinaryReader reader)
Defines a contract used by grouping functions to find information about the current group being evalu...
SqlExpression Evaluate()
Statically evaluates the expression, outside any context.
static SqlBinaryExpression NotEqual(SqlExpression left, SqlExpression right)
static SqlBinaryExpression AnyEqual(SqlExpression left, SqlExpression right)
static readonly ISqlParser Expression
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
static SqlBinaryExpression XOr(SqlExpression left, SqlExpression right)
An interface used to prepare a SqlExpression object.
static SqlBinaryExpression Subtract(SqlExpression left, SqlExpression right)
static SqlBinaryExpression AnyNotEqual(SqlExpression left, SqlExpression right)
ExpressionErrorCodes
Lists all the codes of errors in the expressions domain
static SqlBinaryExpression Like(SqlExpression left, SqlExpression right)
virtual SqlExpression Prepare(IExpressionPreparer preparer)
Represents an expression which has a constant value
Defines the properties of a specific SQL Type and handles the values compatible.
static SqlUnaryExpression UnaryPlus(SqlExpression operand)
SqlParseResult Parse(string input)
Analyzes and parses the input and results an object that describes the parsed nodes in a tree that ca...
static SqlExpression Parse(string s, ISystemContext context)
Parses the given SQL string to an expression that can be evaluated.
An interface to resolve a variable name to a constant object.
static SqlBinaryExpression Any(SqlExpression left, SqlExpressionType anyType, SqlExpression right)
static SqlBinaryExpression AnyGreaterThan(SqlExpression left, SqlExpression right)
An expression that holds a constant value.
SqlExpression Evaluate(IRequest context, IVariableResolver variables, IGroupResolver group)
static SqlFunctionCallExpression FunctionCall(string functionName, SqlExpression[] args)
static SqlBinaryExpression AllEqual(SqlExpression left, SqlExpression right)
static SqlBinaryExpression NotLike(SqlExpression left, SqlExpression right)
static SqlReferenceExpression Reference(ObjectName objectName)
virtual SqlExpression Accept(SqlExpressionVisitor visitor)
static SqlConditionalExpression Conditional(SqlExpression testExpression, SqlExpression ifTrue, SqlExpression ifFalse)
static SqlBinaryExpression AnyGreaterOrEqualThan(SqlExpression left, SqlExpression right)
static SqlFunctionCallExpression FunctionCall(string functionName)
static SqlCastExpression Cast(SqlExpression value, SqlType destType)
static SqlBinaryExpression Binary(SqlExpression left, SqlExpressionType expressionType, SqlExpression right)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlFunctionCallExpression FunctionCall(ObjectName functionName, SqlExpression[] args)
static SqlConstantExpression Constant(object value)
static SqlUnaryExpression Negate(SqlExpression operand)
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
Encapsulates the elements needed to evaluate an SqlExpression
An error that occurs when compiling a input string into a SQL object.
override string ToString()
This interface acts like a marker that indicates if a ISqlNode represents a SQL expression.
A visitor for SqlExpression objects.
static SqlBinaryExpression AnySmallerOrEqualThan(SqlExpression left, SqlExpression right)
static SqlTupleExpression Tuple(SqlExpression expr1, SqlExpression exp2)
static SqlBinaryExpression AllNotEqual(SqlExpression left, SqlExpression right)
static SqlUnaryExpression Unary(SqlExpressionType expressionType, SqlExpression operand)
static SqlBinaryExpression GreaterThan(SqlExpression left, SqlExpression right)
static SqlBinaryExpression GreaterOrEqualThan(SqlExpression left, SqlExpression right)
virtual SqlExpression Visit(SqlExpression expression)
Visits a given SQL expression.
static SqlBinaryExpression Is(SqlExpression left, SqlExpression right)