You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However I get another error: OperationalError: no such column: t1.DateTimeUTC
Looking at the debug code Peewee provides: [2015-07-22 12:04:23,822] [peewee] DEBUG]: ('SELECT "t1"."Id", "t1"."DateTimeUTC", "t1"."Value" FROM (SELECT "t2"."Id" FROM "Log" AS t2 ORDER BY "t2"."DateTimeUTC" DESC LIMIT 20) AS t1 ORDER BY "t1"."DateTimeUTC" ASC', [])
It seems that when Peewee is executing the first line of the last snippet inner_query = Log.select()..., the conversion to SQL is incorrect and only using the ".Id" field instead of all fields in the select() and result in the "no such column" error.
Firstly it seems that the need to add the line inner_query = inner_query.alias('t1') looks like a bug as "t1" is not used in my query.
Secondly there seems to be a bug somewhere in translating select() to SQL when you have an inner query as only one field is being used when all should be used.
Many thanks
P
The text was updated successfully, but these errors were encountered:
Hi. I need to execute the following SQL statement but use Peewee's library to do it and prefer not to use raw sql.
Table "Log" has has this structure:
SQL query needing translation:
I have been helped by the author of Peewee ORM, Charles, with the following code:
This generates an error:
OperationalError: no such column: t1.Id
I was then given a modification to try:
However I get another error:
OperationalError: no such column: t1.DateTimeUTC
Looking at the debug code Peewee provides:
[2015-07-22 12:04:23,822] [peewee] DEBUG]: ('SELECT "t1"."Id", "t1"."DateTimeUTC", "t1"."Value" FROM (SELECT "t2"."Id" FROM "Log" AS t2 ORDER BY "t2"."DateTimeUTC" DESC LIMIT 20) AS t1 ORDER BY "t1"."DateTimeUTC" ASC', [])
It seems that when Peewee is executing the first line of the last snippet
inner_query = Log.select()...
, the conversion to SQL is incorrect and only using the".Id"
field instead of all fields in the select() and result in the "no such column" error.Firstly it seems that the need to add the line
inner_query = inner_query.alias('t1')
looks like a bug as "t1" is not used in my query.Secondly there seems to be a bug somewhere in translating
select()
to SQL when you have an inner query as only one field is being used when all should be used.Many thanks
P
The text was updated successfully, but these errors were encountered: