Ejemplo n.º 1
0
def test_select_with_order_multitenant():
    p = Parser('SELECT * FROM "t1" ORDER BY "f1"')
    assert p.with_schemas("b",
                          "c") == 'SELECT * FROM ' \
                                  '(SELECT *, \'b\' AS __schema FROM "b"."t1" ' \
                                  'UNION ALL ' \
                                  'SELECT *, \'c\' AS __schema FROM "c"."t1") as __query ORDER BY f1'
Ejemplo n.º 2
0
def test_count_multitenant():
    p = Parser('SELECT COUNT(*) FROM "t1"')
    assert p.with_schemas("b",
                          "c") == 'SELECT COUNT(*) FROM ' \
                                  '(SELECT id, \'b\' AS __schema FROM "b"."t1" ' \
                                  'UNION ALL ' \
                                  'SELECT id, \'c\' AS __schema FROM "c"."t1") as __count'
Ejemplo n.º 3
0
def test_select_multitenant():
    p = Parser('SELECT * FROM "t1"')
    assert p.with_schemas(
        "b", "c"
    ) == 'SELECT * FROM (SELECT *, \'b\' AS __schema FROM "b"."t1" UNION ALL SELECT *, \'c\' AS __schema FROM "c"."t1") as __query'