MCPcopy
hub / github.com/andialbrecht/sqlparse / test_grouping_alias

Function test_grouping_alias

tests/test_grouping.py:313–332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

311
312
313def test_grouping_alias():
314 s = 'select foo as bar from mytable'
315 p = sqlparse.parse(s)[0]
316 assert str(p) == s
317 assert p.tokens[2].get_real_name() == 'foo'
318 assert p.tokens[2].get_alias() == 'bar'
319 s = 'select foo from mytable t1'
320 p = sqlparse.parse(s)[0]
321 assert str(p) == s
322 assert p.tokens[6].get_real_name() == 'mytable'
323 assert p.tokens[6].get_alias() == 't1'
324 s = 'select foo::integer as bar from mytable'
325 p = sqlparse.parse(s)[0]
326 assert str(p) == s
327 assert p.tokens[2].get_alias() == 'bar'
328 s = ('SELECT DISTINCT '
329 '(current_database())::information_schema.sql_identifier AS view')
330 p = sqlparse.parse(s)[0]
331 assert str(p) == s
332 assert p.tokens[4].get_alias() == 'view'
333
334
335def test_grouping_alias_case():

Callers

nothing calls this directly

Calls 2

get_real_nameMethod · 0.45
get_aliasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…