ts-safeql / safeql

Validate and auto-generate TypeScript types from raw SQL queries in PostgreSQL.
https://safeql.dev
MIT License
1.34k stars 22 forks source link

Make LIKE and NOT LIKE expressions non-nullable #271

Closed karlhorky closed 2 weeks ago

karlhorky commented 2 weeks ago

Fix column being incorrectly inferred as nullable:

// 💥 Query has incorrect type annotation.
//  Expected: { is_guest: boolean; }
//  Actual: { is_guest: boolean | null; }[]
await sql<{ is_guest: boolean }[]>`
  SELECT
    lecturers.id,
    users.email NOT LIKE '%@upleveled.io' AS is_guest
  FROM
    lecturers
    INNER JOIN users ON lecturers.user_id = users.id
`;
changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 5fa3e40cd6b82ad3f58b1b212da63ea6ff330622

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages | Name | Type | | ---------------------------------------- | ----- | | @ts-safeql/generate | Patch | | @ts-safeql/eslint-plugin | Patch | | @ts-safeql/shared | Patch | | @ts-safeql/sql-ast | Patch | | @ts-safeql-demos/basic-flat-config | Patch | | @ts-safeql-demos/basic-migrations-raw | Patch | | @ts-safeql-demos/basic-transform-type | Patch | | @ts-safeql-demos/basic | Patch | | @ts-safeql-demos/big-project | Patch | | @ts-safeql-demos/config-file-flat-config | Patch | | @ts-safeql-demos/from-config-file | Patch | | @ts-safeql-demos/multi-connections | Patch | | @ts-safeql-demos/playground | Patch | | @ts-safeql-demos/postgresjs-custom-types | Patch | | @ts-safeql-demos/postgresjs-demo | Patch | | @ts-safeql-demos/vercel-postgres | Patch | | @ts-safeql/test-utils | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **safeql** | ⬜️ Ignored ([Inspect](https://vercel.com/newbie012s-projects/safeql/c42KhwYTz2z6UX5wycPDcDBEKGJ8)) | [Visit Preview](https://safeql-git-make-like-expr-nonnullable-newbie012s-projects.vercel.app) | | Sep 22, 2024 7:05am |
karlhorky commented 2 weeks ago

@Newbie012 this PR also good for merging? Or does it still need work?

karlhorky commented 2 weeks ago

Thanks for the review, merge and publish of @ts-safeql/eslint-plugin@3.4.5!