ygrek / sqlgg

SQL Guided (code) Generator
https://ygrek.org/p/sqlgg/
GNU General Public License v2.0
62 stars 20 forks source link

take unique constraint into account when computing cardinality #82

Closed cyberhuman closed 4 years ago

cyberhuman commented 4 years ago

For example:

CREATE TABLE TEST (
  id INTEGER PRIMARY KEY,
  field VARCHAR(50) NOT NULL,
  time TIMESTAMP NULL,
  UNIQUE KEY field_unique ( field ),
  UNIQUE KEY time_unique ( time )
);

SELECT * FROM test WHERE id = @id; -- should use `select_one_maybe`

SELECT * FROM test WHERE field = @field; -- should use `select_one_maybe`

SELECT * FROM test WHERE time = @time; -- should use `select` since the column is nullable

I know it's possible to achieve a similar behaviour with LIMIT 1. This is just a convenience feature request.

cyberhuman commented 4 years ago

oops, duplicate of #8