Repository navigation
SQLSage: local review of PostgreSQL SELECTs generated by Drizzle #6507
Figo5
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
If you're investigating a PostgreSQL SELECT generated by Drizzle, I've made a local CLI to review the SQL alongside its schema: SQLSage. I maintain the project; this post was prepared with AI assistance.
SQLSage explains the SELECT and flags supported correctness/performance risks. One example is
ORDER BY created_at DESC LIMIT 50: whencreated_atisn't unique, it can flag ties at the boundary and suggest a unique tiebreaker as optional cleanup if stable results matter. It doesn't assume that every tie is a bug.I checked the file workflow with a Drizzle 0.45.4 generated SELECT and matching supported CREATE TABLE DDL (a synthetic fixture, with no database execution). To try your own:
.toSQL()to get your SELECT text and save that SQL string asquery.sql.schema.sql; check it against SQLSage's supported inputs. This step needs SQL DDL, not the TypeScript table definitions.The MIT CLI is free. This file workflow doesn't execute the query, upload inputs, connect to your database or require credentials. It reads SQL and supported DDL/catalog metadata; it isn't a Drizzle plugin and doesn't read TypeScript schemas directly. Saved PostgreSQL plans are optional. Parameters such as
$1bind, but advice is weaker without values; reports don't prove correct results or a speedup.For one real SELECT you're already investigating, did the report suggest a useful next check, get something wrong, or fail on your input? A plain-language reply here is enough; the feedback issue is optional. Keep SQL, schemas, plans, full reports, credentials and private data local.
All reactions