Exemple #1
0
 public OuterJoin(bool isLeftJoin,
                  TableReference leftTableRef,
                  TableReference rightTableRef,
                  IList<string> @using)
     : this(isLeftJoin, leftTableRef, rightTableRef, null, @using)
 {
 }
Exemple #2
0
 public OuterJoin(bool isLeftJoin,
                  TableReference leftTableRef,
                  TableReference rightTableRef,
                  IExpression onCond)
     : this(isLeftJoin, leftTableRef, rightTableRef, onCond, null)
 {
 }
 public StraightJoin(TableReference leftTableRef,
                     TableReference rightTableRef,
                     IExpression onCond)
 {
     LeftTableRef = leftTableRef;
     RightTableRef = rightTableRef;
     this.onCond = onCond;
 }
Exemple #4
0
 public NaturalJoin(bool isOuter, bool isLeft,
                    TableReference leftTableRef,
                    TableReference rightTableRef)
 {
     IsOuter = isOuter;
     IsLeft = isLeft;
     LeftTableRef = leftTableRef;
     RightTableRef = rightTableRef;
 }
Exemple #5
0
 private InnerJoin(TableReference leftTableRef,
                   TableReference rightTableRef,
                   IExpression onCond,
                   IList<string> @using)
 {
     LeftTableRef = leftTableRef;
     RightTableRef = rightTableRef;
     this.onCond = onCond;
     this.@using = EnsureListType(@using);
 }
Exemple #6
0
 private OuterJoin(bool isLeftJoin,
                   TableReference leftTableRef,
                   TableReference rightTableRef,
                   IExpression onCond,
                   IList<string> @using)
 {
     this.isLeftJoin = isLeftJoin;
     LeftTableRef = leftTableRef;
     RightTableRef = rightTableRef;
     OnCond = onCond;
     Using = EnsureListType(@using);
 }
 public StraightJoin(TableReference leftTableRef,
                     TableReference rightTableRef)
     : this(leftTableRef, rightTableRef, null)
 {
 }
Exemple #8
0
 public InnerJoin(TableReference leftTableRef,
                  TableReference rightTableRef,
                  IList<string> @using)
     : this(leftTableRef, rightTableRef, null, @using)
 {
 }
Exemple #9
0
 public InnerJoin(TableReference leftTableRef,
                  TableReference rightTableRef,
                  IExpression onCond)
     : this(leftTableRef, rightTableRef, onCond, null)
 {
 }
Exemple #10
0
 public InnerJoin(TableReference leftTableRef, TableReference rightTableRef)
     : this(leftTableRef, rightTableRef, null, null)
 {
 }
        /// <exception cref="System.SqlSyntaxErrorException" />
        private TableReference BuildTableReference(TableReference @ref)
        {
            for (;;)
            {
                IExpression on;
                IList<string> @using;
                TableReference temp;
                var isOut = false;
                var isLeft = true;
                switch (lexer.Token())
                {
                    case MySqlToken.KwInner:
                    case MySqlToken.KwCross:
                    {
                        lexer.NextToken();
                        goto case MySqlToken.KwJoin;
                    }

                    case MySqlToken.KwJoin:
                    {
                        lexer.NextToken();
                        temp = TableFactor();
                        switch (lexer.Token())
                        {
                            case MySqlToken.KwOn:
                            {
                                lexer.NextToken();
                                on = exprParser.Expression();
                                @ref = new InnerJoin(@ref, temp, on);
                                break;
                            }

                            case MySqlToken.KwUsing:
                            {
                                lexer.NextToken();
                                Match(MySqlToken.PuncLeftParen);
                                @using = IdNameList();
                                @ref = new InnerJoin(@ref, temp, @using);
                                break;
                            }

                            default:
                            {
                                @ref = new InnerJoin(@ref, temp);
                                break;
                            }
                        }
                        break;
                    }

                    case MySqlToken.KwStraightJoin:
                    {
                        lexer.NextToken();
                        temp = TableFactor();
                        switch (lexer.Token())
                        {
                            case MySqlToken.KwOn:
                            {
                                lexer.NextToken();
                                on = exprParser.Expression();
                                @ref = new StraightJoin(@ref, temp, on);
                                break;
                            }

                            default:
                            {
                                @ref = new StraightJoin(@ref, temp);
                                break;
                            }
                        }
                        break;
                    }

                    case MySqlToken.KwRight:
                    {
                        isLeft = false;
                        goto case MySqlToken.KwLeft;
                    }

                    case MySqlToken.KwLeft:
                    {
                        lexer.NextToken();
                        if (lexer.Token() == MySqlToken.KwOuter)
                        {
                            lexer.NextToken();
                        }
                        Match(MySqlToken.KwJoin);
                        temp = TableReference();
                        switch (lexer.Token())
                        {
                            case MySqlToken.KwOn:
                            {
                                lexer.NextToken();
                                on = exprParser.Expression();
                                @ref = new OuterJoin(isLeft, @ref, temp, on);
                                break;
                            }

                            case MySqlToken.KwUsing:
                            {
                                lexer.NextToken();
                                Match(MySqlToken.PuncLeftParen);
                                @using = IdNameList();
                                @ref = new OuterJoin(isLeft, @ref, temp, @using);
                                break;
                            }

                            default:
                            {
                                var condition = temp.RemoveLastConditionElement();
                                if (condition is IExpression)
                                {
                                    @ref = new OuterJoin(isLeft, @ref, temp, (IExpression)condition);
                                }
                                else
                                {
                                    if (condition is IList)
                                    {
                                        @ref = new OuterJoin(isLeft, @ref, temp, (IList<string>)condition);
                                    }
                                    else
                                    {
                                        throw Err("conditionExpr cannot be null for outer join");
                                    }
                                }
                                break;
                            }
                        }
                        break;
                    }

                    case MySqlToken.KwNatural:
                    {
                        lexer.NextToken();
                        switch (lexer.Token())
                        {
                            case MySqlToken.KwRight:
                            {
                                isLeft = false;
                                goto case MySqlToken.KwLeft;
                            }

                            case MySqlToken.KwLeft:
                            {
                                lexer.NextToken();
                                if (lexer.Token() == MySqlToken.KwOuter)
                                {
                                    lexer.NextToken();
                                }
                                isOut = true;
                                goto case MySqlToken.KwJoin;
                            }

                            case MySqlToken.KwJoin:
                            {
                                lexer.NextToken();
                                temp = TableFactor();
                                @ref = new NaturalJoin(isOut, isLeft, @ref, temp);
                                break;
                            }

                            default:
                            {
                                throw Err("unexpected token after NATURAL for natural join:" + lexer.Token());
                            }
                        }
                        break;
                    }

                    default:
                    {
                        return @ref;
                    }
                }
            }
        }
 /// <exception cref="System.SqlSyntaxErrorException" />
 private TableReferences BuildTableReferences(TableReference @ref)
 {
     IList<TableReference> list;
     if (lexer.Token() == MySqlToken.PuncComma)
     {
         list = new List<TableReference>();
         list.Add(@ref);
         for (; lexer.Token() == MySqlToken.PuncComma;)
         {
             lexer.NextToken();
             @ref = TableReference();
             list.Add(@ref);
         }
     }
     else
     {
         list = new List<TableReference>(1);
         list.Add(@ref);
     }
     return new TableReferences(list);
 }
Exemple #13
0
 public InnerJoin(TableReference leftTableRef,
                  TableReference rightTableRef,
                  IList <string> @using)
     : this(leftTableRef, rightTableRef, null, @using)
 {
 }
Exemple #14
0
 public InnerJoin(TableReference leftTableRef,
                  TableReference rightTableRef,
                  IExpression onCond)
     : this(leftTableRef, rightTableRef, onCond, null)
 {
 }
Exemple #15
0
 public InnerJoin(TableReference leftTableRef, TableReference rightTableRef)
     : this(leftTableRef, rightTableRef, null, null)
 {
 }