metarhia/metasql

Implement SELECT DISTINCT(...)

OleksiiKachan opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Recently I had to build select distinct using bookshelf/knex which was pretty frustrating. and realized that metasql is lacking this feature

Describe the solution you'd like
was thinking of something like
db.select(table, ["DISTINCT(column)"])
current implementation treats "DISTINCT(COLUMN)" as a column name
or
db.select(table, ["column1", {column2: 'distinct'}]).groupBy(column2)
opened for other suggestions

Case 1

db.select('Entity1', ['column1', 'column2']).distinct()
SELECT DISTINCT "column1", "column2" FROM "Entity1"

Case 2

db.count('Entity1', ['column1']).distinct()
SELECT COUNT(DISTINCT "column1") FROM "Entity1"

distinct is not a function