Exemplo n.º 1
0
 public PredicateSegment(int startIndex, int stopIndex, ColumnSegment column, IPredicateRightValue rightValue)
 {
     _startIndex = startIndex;
     _stopIndex  = stopIndex;
     _column     = column;
     _rightValue = rightValue;
 }
Exemplo n.º 2
0
        private IASTNode CreateCompareSegment(MySqlCommandParser.BooleanPrimaryContext ctx)
        {
            IASTNode leftValue = Visit(ctx.booleanPrimary());

            if (!(leftValue is ColumnSegment))
            {
                return(leftValue);
            }
            IPredicateRightValue rightValue = (IPredicateRightValue)CreatePredicateRightValue(ctx);

            return(new PredicateSegment(ctx.Start.StartIndex, ctx.Stop.StopIndex, (ColumnSegment)leftValue, rightValue));
        }
Exemplo n.º 3
0
 public static IRouteValue Generate(IPredicateRightValue predicateRightValue, Column column, ParameterContext parameterContext)
 {
     if (predicateRightValue is PredicateCompareRightValue predicateCompareRightValue)
     {
         return(_conditionValueCompareOperatorGenerator.Generate(predicateCompareRightValue, column, parameterContext));
     }
     if (predicateRightValue is PredicateInRightValue predicateInRightValue)
     {
         return(_conditionValueInOperatorGenerator.Generate(predicateInRightValue, column, parameterContext));
     }
     if (predicateRightValue is PredicateBetweenRightValue predicateBetweenRightValue)
     {
         return(_conditionValueBetweenOperatorGenerator.Generate(predicateBetweenRightValue, column, parameterContext));
     }
     return(null);
 }
 private object GetShardingValue(AndPredicateSegment andPredicate, ParameterContext parameterContext, String shardingColumn)
 {
     foreach (var predicate in andPredicate.GetPredicates())
     {
         if (!shardingColumn.EqualsIgnoreCase(predicate.GetColumn().GetIdentifier().GetValue()))
         {
             continue;
         }
         IPredicateRightValue rightValue = predicate.GetPredicateRightValue();
         if (rightValue is PredicateCompareRightValue predicateCompareRightValue)
         {
             var segment = predicateCompareRightValue.GetExpression();
             return(GetPredicateCompareShardingValue(segment, parameterContext));
         }
         if (rightValue is PredicateInRightValue predicateInRightValue)
         {
             ICollection <IExpressionSegment> segments = predicateInRightValue.SqlExpressions;
             return(GetPredicateInShardingValue(segments, parameterContext));
         }
     }
     return(null);
 }
 public IRouteValue Generate(IPredicateRightValue predicateRightValue, Column column, ParameterContext parameterContext)
 {
     return(Generate((PredicateInRightValue)predicateRightValue, column, parameterContext));
 }