20
20
Table ,
21
21
)
22
22
from sqlalchemy .schema import CreateTable
23
+ from sqlalchemy .sql import column , table
23
24
24
25
from trino .sqlalchemy .dialect import TrinoDialect
25
26
26
27
metadata = MetaData ()
27
- table = Table (
28
+ table_without_catalog = Table (
28
29
'table' ,
29
30
metadata ,
30
31
Column ('id' , Integer ),
@@ -45,26 +46,26 @@ def dialect():
45
46
46
47
47
48
def test_limit_offset (dialect ):
48
- statement = select (table ).limit (10 ).offset (0 )
49
+ statement = select (table_without_catalog ).limit (10 ).offset (0 )
49
50
query = statement .compile (dialect = dialect )
50
51
assert str (query ) == 'SELECT "table".id, "table".name \n FROM "table"\n OFFSET :param_1\n LIMIT :param_2'
51
52
52
53
53
54
def test_limit (dialect ):
54
- statement = select (table ).limit (10 )
55
+ statement = select (table_without_catalog ).limit (10 )
55
56
query = statement .compile (dialect = dialect )
56
57
assert str (query ) == 'SELECT "table".id, "table".name \n FROM "table"\n LIMIT :param_1'
57
58
58
59
59
60
def test_offset (dialect ):
60
- statement = select (table ).offset (0 )
61
+ statement = select (table_without_catalog ).offset (0 )
61
62
query = statement .compile (dialect = dialect )
62
63
assert str (query ) == 'SELECT "table".id, "table".name \n FROM "table"\n OFFSET :param_1'
63
64
64
65
65
66
def test_cte_insert_order (dialect ):
66
- cte = select (table ).cte ('cte' )
67
- statement = insert (table ).from_select (table .columns , cte )
67
+ cte = select (table_without_catalog ).cte ('cte' )
68
+ statement = insert (table_without_catalog ).from_select (table_without_catalog .columns , cte )
68
69
query = statement .compile (dialect = dialect )
69
70
assert str (query ) == \
70
71
'INSERT INTO "table" (id, name) WITH cte AS \n ' \
@@ -89,3 +90,9 @@ def test_catalogs_create_table(dialect):
89
90
'\t id INTEGER\n ' \
90
91
')\n ' \
91
92
'\n '
93
+
94
+
95
+ def test_table_clause (dialect ):
96
+ statement = select (table ("user" , column ("id" ), column ("name" ), column ("description" )))
97
+ query = statement .compile (dialect = dialect )
98
+ assert str (query ) == 'SELECT user.id, user.name, user.description \n FROM user'
0 commit comments