question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query aliases are not being replaced completly

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
RossRogerscommented, Oct 26, 2016

Good night! The combined documentation for IBM DB2 LUW 10.5 is 24,051 pages.

0reactions
RossRogerscommented, Oct 26, 2016

Yeah, I kinda recommend leaving off DB2, if you’re somehow able to do so.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found