select(distinct=...) may produce faulty sql for sqlite
See original GitHub issueThis one works:
In [45]: db().select(db.player.country, distinct = True)
Out[45]: <Rows (40)>
In [46]: db._lastsql
Out[46]: 'SELECT DISTINCT player.country FROM player;'
But the other option given in the book does not:
In [47]: db().select(db.player.country, distinct = db.player.country)
OperationalError: near "ON": syntax error
In [48]: db._lastsql
Out[48]: 'SELECT DISTINCT ON (player.country) player.country FROM player;'
I didn’t test it with other DB engines since I don’t currently have one installed.
Related to https://github.com/web2py/web2py/issues/1129
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
select(distinct=...) may produce faulty sql for sqlite · Issue #1129
This one works: In [45]: db().select(db.player.country, distinct = True) Out[45]: In [46]: db._lastsql Out[46]: 'SELECT DISTINCT player.country FROM player ...
Read more >Problem with sqlite want distinct attribute when creating view
I'm trying to create a view from different tables. One table contains attributes such as year, name, and country the second one contains ......
Read more >SQLite SELECT DISTINCT - Removing Duplicate in Result ...
This tutorial shows you how to use SQLite SELECT DISTINCT clause to remove duplicate rows by applying the DISTINCT clause on one column...
Read more >sqlite - Get distinct values through direct query of an index
I've never used SQLite so bear with me here. But it seems as if this problem is common among many RDBMS platforms. When...
Read more >Distinguishing CREATE TABLE failure (already exists) from ...
Is there any good way to distinguish CREATE TABLE failure due to table already exists from other possible failures?
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
@niphlod Damn, I ended the refactoring and forgotten this. We should re-start a discussion. I vote for the
SyntaxError
on sqlite when usingDISTINCT ON
.start away, my previous semi-detailed comment pretty much lays every path that can be taken.