Skip to content

Commit c2a5848

Browse files
committed
alias
1 parent 8a71992 commit c2a5848

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

qstrings/Q.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __new__(
6868
qstr.id = int(f"{datetime.now():%y%m%d%H%M%S%f}")
6969
qstr.refs = refs # references used to create the Q string
7070
qstr.file = _path if file else None
71+
qstr.alias = kwargs.get("alias")
7172
qstr.exec_id = 0
7273
qstr.duration = 0.0
7374
qstr._quiet = kwargs.get("quiet", False)

tests/test_Q.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def test_from_file():
4242
assert q.file and q.file.name == "test_format.sql"
4343

4444

45+
def test_alias():
46+
q = Q("SELECT 42 AS answer", alias="blah")
47+
assert q.alias == "blah"
48+
49+
4550
def test_parse_error():
4651
q = Q("SELE 42")
4752
assert q.ast_errors

0 commit comments

Comments
 (0)