Query aliases are not being replaced completly
See original GitHub issueI’m running a DB2 and for some reason some parts of the query aliases are not getting replaced.
My DB gets this query: SELECT {MYDB2.Example}.{id}, {MYDB2.Example}.{ARTNR} FROM {MYDB2.Example}
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 232, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 256, in __iter__
self._fetch_all()
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql()
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/fen/PycharmProjects/wisainfo/env/local/lib/python2.7/site-packages/django_pyodbc/base.py", line 490, in execute
raise utils.DatabaseError(*e.args)
DatabaseError: ('42000', '[42000] [IBM][CLI Driver] CLI0118E Invalid SQL syntax. SQLSTATE=37000 (-99999) (SQLExecDirectW)')`
My Model:
class Example(models.Model):
artnr = models.TextField()
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Why can't I use column aliases in the next SELECT expression?
The solution is to encapsulate the query in a subquery and then the alias is available outside. SELECT stddev_time, max_time, avg_time, min_time ...
Read more >How to Use Aliases in SQL Queries - LearnSQL.com
There are several ways to use aliases in your SQL queries. This article shows you how, using simple explanations and helpful examples.
Read more >Using a field alias in Query does not work with some third ...
Using a field alias in Query does not work with some third-party databases ... This behavior is the result of a design change...
Read more >SQL: ALIASES - TechOnTheNet
SQL ALIASES can be used to create a temporary name for columns or tables. ... However, it is not generally good practice to...
Read more >SQL Alias: A Guide to the SQL Aliases and the SQL AS Keyword
The SQL AS keyword can be used to define an SQL alias. You can define column or table aliases to improve readability and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good night! The combined documentation for IBM DB2 LUW 10.5 is 24,051 pages.
Yeah, I kinda recommend leaving off DB2, if you’re somehow able to do so.