示例#1
0
    def test_stop_on(self):
        (t1, t2, t3) = (table1, table2, table3)
        
        j1= t1.join(t2, t1.c.col1==t2.c.col1)
        j2 = j1.join(t3, t2.c.col1==t3.c.col1)
        
        s = select([t1]).select_from(j1).alias()
        
        self.assert_compile(sql_util.splice_joins(s, j2), 
            "(SELECT table1.col1 AS col1, table1.col2 AS col2, table1.col3 AS col3 FROM table1 JOIN table2 "\
            "ON table1.col1 = table2.col1) AS anon_1 JOIN table2 ON anon_1.col1 = table2.col1 JOIN table3 "\
            "ON table2.col1 = table3.col1"
        )

        self.assert_compile(sql_util.splice_joins(s, j2, j1), 
            "(SELECT table1.col1 AS col1, table1.col2 AS col2, table1.col3 AS col3 FROM table1 "\
            "JOIN table2 ON table1.col1 = table2.col1) AS anon_1 JOIN table3 ON table2.col1 = table3.col1")
示例#2
0
    def test_stop_on(self):
        (t1, t2, t3) = (table1, table2, table3)

        j1 = t1.join(t2, t1.c.col1 == t2.c.col1)
        j2 = j1.join(t3, t2.c.col1 == t3.c.col1)

        s = select([t1]).select_from(j1).alias()

        self.assert_compile(sql_util.splice_joins(s, j2),
            "(SELECT table1.col1 AS col1, table1.col2 AS col2, table1.col3 AS col3 FROM table1 JOIN table2 "\
            "ON table1.col1 = table2.col1) AS anon_1 JOIN table2 ON anon_1.col1 = table2.col1 JOIN table3 "\
            "ON table2.col1 = table3.col1"
        )

        self.assert_compile(sql_util.splice_joins(s, j2, j1),
            "(SELECT table1.col1 AS col1, table1.col2 AS col2, table1.col3 AS col3 FROM table1 "\
            "JOIN table2 ON table1.col1 = table2.col1) AS anon_1 JOIN table3 ON table2.col1 = table3.col1")
示例#3
0
    def test_splice_2(self):
        t2a = table2.alias()
        t3a = table3.alias()
        j1 = table1.join(t2a, table1.c.col1==t2a.c.col1).join(t3a, t2a.c.col2==t3a.c.col2)
        
        t2b = table4.alias()
        j2 = table1.join(t2b, table1.c.col3==t2b.c.col3)
        
        self.assert_compile(sql_util.splice_joins(table1, j1), 
            "table1 JOIN table2 AS table2_1 ON table1.col1 = table2_1.col1 "\
            "JOIN table3 AS table3_1 ON table2_1.col2 = table3_1.col2")
            
        self.assert_compile(sql_util.splice_joins(table1, j2), "table1 JOIN table4 AS table4_1 ON table1.col3 = table4_1.col3")

        self.assert_compile(sql_util.splice_joins(sql_util.splice_joins(table1, j1), j2), 
            "table1 JOIN table2 AS table2_1 ON table1.col1 = table2_1.col1 "\
            "JOIN table3 AS table3_1 ON table2_1.col2 = table3_1.col2 "\
            "JOIN table4 AS table4_1 ON table1.col3 = table4_1.col3")
 def test_stop_on(self):
     t1, t2, t3 = table1, table2, table3
     j1 = t1.join(t2, t1.c.col1 == t2.c.col1)
     j2 = j1.join(t3, t2.c.col1 == t3.c.col1)
     s = select([t1]).select_from(j1).alias()
     self.assert_compile(sql_util.splice_joins(s, j2),
                         '(SELECT table1.col1 AS col1, table1.col2 '
                         'AS col2, table1.col3 AS col3 FROM table1 '
                         'JOIN table2 ON table1.col1 = table2.col1) '
                         'AS anon_1 JOIN table2 ON anon_1.col1 = '
                         'table2.col1 JOIN table3 ON table2.col1 = '
                         'table3.col1')
     self.assert_compile(sql_util.splice_joins(s, j2, j1),
                         '(SELECT table1.col1 AS col1, table1.col2 '
                         'AS col2, table1.col3 AS col3 FROM table1 '
                         'JOIN table2 ON table1.col1 = table2.col1) '
                         'AS anon_1 JOIN table3 ON table2.col1 = '
                         'table3.col1')
示例#5
0
 def test_stop_on(self):
     t1, t2, t3 = table1, table2, table3
     j1 = t1.join(t2, t1.c.col1 == t2.c.col1)
     j2 = j1.join(t3, t2.c.col1 == t3.c.col1)
     s = select([t1]).select_from(j1).alias()
     self.assert_compile(
         sql_util.splice_joins(s, j2),
         '(SELECT table1.col1 AS col1, table1.col2 '
         'AS col2, table1.col3 AS col3 FROM table1 '
         'JOIN table2 ON table1.col1 = table2.col1) '
         'AS anon_1 JOIN table2 ON anon_1.col1 = '
         'table2.col1 JOIN table3 ON table2.col1 = '
         'table3.col1')
     self.assert_compile(
         sql_util.splice_joins(s, j2, j1),
         '(SELECT table1.col1 AS col1, table1.col2 '
         'AS col2, table1.col3 AS col3 FROM table1 '
         'JOIN table2 ON table1.col1 = table2.col1) '
         'AS anon_1 JOIN table3 ON table2.col1 = '
         'table3.col1')
示例#6
0
    def test_splice_2(self):
        t2a = table2.alias()
        t3a = table3.alias()
        j1 = table1.join(t2a, table1.c.col1 == t2a.c.col1).join(
            t3a, t2a.c.col2 == t3a.c.col2)

        t2b = table4.alias()
        j2 = table1.join(t2b, table1.c.col3 == t2b.c.col3)

        self.assert_compile(sql_util.splice_joins(table1, j1),
            "table1 JOIN table2 AS table2_1 ON table1.col1 = table2_1.col1 "\
            "JOIN table3 AS table3_1 ON table2_1.col2 = table3_1.col2")

        self.assert_compile(
            sql_util.splice_joins(table1, j2),
            "table1 JOIN table4 AS table4_1 ON table1.col3 = table4_1.col3")

        self.assert_compile(sql_util.splice_joins(sql_util.splice_joins(table1, j1), j2),
            "table1 JOIN table2 AS table2_1 ON table1.col1 = table2_1.col1 "\
            "JOIN table3 AS table3_1 ON table2_1.col2 = table3_1.col2 "\
            "JOIN table4 AS table4_1 ON table1.col3 = table4_1.col3")
示例#7
0
 def test_splice(self):
     (t1, t2, t3, t4) = (table1, table2, table1.alias(), table2.alias())
     
     j = t1.join(t2, t1.c.col1==t2.c.col1).join(t3, t2.c.col1==t3.c.col1).join(t4, t4.c.col1==t1.c.col1)
     
     s = select([t1]).where(t1.c.col2<5).alias()
     
     self.assert_compile(sql_util.splice_joins(s, j), 
         "(SELECT table1.col1 AS col1, table1.col2 AS col2, "\
         "table1.col3 AS col3 FROM table1 WHERE table1.col2 < :col2_1) AS anon_1 "\
         "JOIN table2 ON anon_1.col1 = table2.col1 JOIN table1 AS table1_1 ON table2.col1 = table1_1.col1 "\
         "JOIN table2 AS table2_1 ON table2_1.col1 = anon_1.col1")
示例#8
0
    def test_splice(self):
        (t1, t2, t3, t4) = (table1, table2, table1.alias(), table2.alias())

        j = t1.join(t2, t1.c.col1 == t2.c.col1).join(
            t3, t2.c.col1 == t3.c.col1).join(t4, t4.c.col1 == t1.c.col1)

        s = select([t1]).where(t1.c.col2 < 5).alias()

        self.assert_compile(sql_util.splice_joins(s, j),
            "(SELECT table1.col1 AS col1, table1.col2 AS col2, "\
            "table1.col3 AS col3 FROM table1 WHERE table1.col2 < :col2_1) AS anon_1 "\
            "JOIN table2 ON anon_1.col1 = table2.col1 JOIN table1 AS table1_1 ON table2.col1 = table1_1.col1 "\
            "JOIN table2 AS table2_1 ON table2_1.col1 = anon_1.col1")