MySQL Left join error, Unknown column
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
Fix Released
|
Undecided
|
Gustavo Niemeyer |
Bug Description
Currently, the expression builder dont put parenthesis between the FROM and JOIN and this create a bug. In my case, the LEFT JOIN was only on the tests class. With the parenthesis, it work perfectly
Modification I made so it work:
In expr.py in the build_tables function
ORIGINAL VERSION:
def build_tables(
...
# Remove tables that were seen in join statements.
table_stmts -= state.join_tables
state.pop()
result = ", ".join(
if half_join_stmts:
result += " " + " ".join(
return "".join(result)
...
SQL query with original version:
SELECT platforms.name, results.`time` FROM buffer_types, results, tests LEFT JOIN platforms ON results.platform = plat
forms.id WHERE tests.kernel_type = buffer_types.id AND buffer_types.name = %s AND tests.serial_no = results.test ORDER B
Y platforms.name ASC
Exception catched:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\
return self.func(*args)
File "E:\current\
for res in results:
File "C:\Python25\
result = self._store.
File "C:\Python25\
raw_cursor = self.raw_
File "C:\Python25\
raw_
File "C:\Python25\
self.
File "C:\Python25\
raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'results.platform' in 'on clause'")
MODIFIED VERSION:
....
# Remove tables that were seen in join statements.
table_stmts -= state.join_tables
state.pop()
result = "(" + ", ".join(
result += ", ".join(
if half_join_stmts:
result += " " + " ".join(
return "".join(result)
....
SQL query with modified version:
SELECT platforms.name, results.`time` FROM (buffer_types, results, tests) LEFT JOIN platforms ON results.platform = plat
forms.id WHERE tests.kernel_type = buffer_types.id AND buffer_types.name = %s AND tests.serial_no = results.test ORDER B
Y platforms.name ASC
Modified version work
See following documentation: http://
Related branches
description: | updated |
Changed in storm: | |
assignee: | nobody → niemeyer |
Changed in storm: | |
status: | Fix Committed → Fix Released |
The optimal fix would be for the LEFT JOIN's to be paired with the tables we're left joining to. So your statement would become:
... FROM ROM buffer_types, results LEFT JOIN platforms ON results.platform = platforms.id, tests ...
I agree that the current SQL looks incorrect.