![]() If you need any more information, do let me know, and I'll be happy to help. Assume that we have a table saledetails with the below rows. just creating the list by looping over the result set), it'd be nice to be able to alias nested queries within peewee. Lets get started, but first, we will look into the data we will be using in our examples. While I can work around this by performing the Group_Concat outside of peewee (i.e. "OperationalError: (1248, 'Every derived table must have its own alias')"Ī solution would be to have an alias pool for queries that make use of the 'from_' function, for nested queries.Ī test to demonstrate an error when using nested queries in peewee (MySQL): But also note the columns in the sub query select list must have unique names bit. ![]() You can find more about inline views, derived tables, and common table expressions in this older post of mine. A start would be giving the derived tables alias names. This make sense when you think about query optimization engines work, but that’s a story for a much longer post. ![]() When running the same script, while using the MySQL config, you will get the following error upon visiting the root of the app. MySQL requires that every derived table have its own alias. Using SQLITE, upon visiting the root of the app ( you will get a list of IDs resulting from the Group_Concat (1,2,3,4,5). Please see the below link to a gist that demonstrates this issue. The issue is - as the error message describes - that the table that is derived after using the 'from_' function is not provided with an alias. You can omit the () 's around the 2 inner queries in your UNION ALL BTW. So, something like (SELECT foo FROM bar) thisisaderivedtablealias. While playing around with the 'from_' function that was introduced recently (I believe it was pretty recent (see !topic/peewee-orm/FSHhd9lZvUE), and ran into a bit of an issue when attempting to use the same query that worked under SQLITE, on a MySQL database. 1 You'd add an alias, by gving subqueries a name after your closing ).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |