Releases: ts-safeql/safeql
@ts-safeql/generate@1.0.0
Major Changes
-
f874247: # Enhanced Nullability Checks
Previously, SafeQL adopted an optimistic standpoint, presuming a returned column to be non-nullable until established otherwise. Albeit this assumption worked fine in a majority of situations, it occasionally led to false positives. To illustrate, let's take a case of
SELECT max(col) FROM ...
. Previously, such a query returned a non-nullable column, disregarding that themax
function could returnnull
if the result set contained no rows (unlike other functions such ascount
).// ❌ Previously, this would be considered non-nullable const result = await sql<{ max: number }>`SELECT max(col) FROM tbl WHERE FALSE`; // ✅ Now, this is considered nullable const result = await sql<{ max: number | null }>`SELECT max(col) FROM tbl WHERE FALSE`; // ✅✅ You could add a fallback via `coalesce` to make it non-nullable again const result = await sql<{ max: number }>`SELECT coalesce(max(col), '0') FROM tbl WHERE FALSE`;
Moreover, the nullability checks for WHERE clauses have been enhanced.
// ❌ Previously, SafeQL annotated a nullable column as null, // even though it was checked for nullability: const result = await sql<{ text_nullable: string | null }>` SELECT text_nullable FROM tbl WHERE text_nullable IS NOT NULL `; // ✅ Now, SafeQL accurately annotates the column as non-nullable const result = await sql<{ text_nullable: string }>` SELECT text_nullable FROM tbl WHERE text_nullable IS NOT NULL `;
Patch Changes
- Updated dependencies [f874247]
- @ts-safeql/shared@0.2.0
- @ts-safeql/test-utils@0.0.12
@ts-safeql/eslint-plugin@2.0.0
Major Changes
-
f874247: # Enhanced Nullability Checks
Previously, SafeQL adopted an optimistic standpoint, presuming a returned column to be non-nullable until established otherwise. Albeit this assumption worked fine in a majority of situations, it occasionally led to false positives. To illustrate, let's take a case of
SELECT max(col) FROM ...
. Previously, such a query returned a non-nullable column, disregarding that themax
function could returnnull
if the result set contained no rows (unlike other functions such ascount
).// ❌ Previously, this would be considered non-nullable const result = await sql<{ max: number }>`SELECT max(col) FROM tbl WHERE FALSE`; // ✅ Now, this is considered nullable const result = await sql<{ max: number | null }>`SELECT max(col) FROM tbl WHERE FALSE`; // ✅✅ You could add a fallback via `coalesce` to make it non-nullable again const result = await sql<{ max: number }>`SELECT coalesce(max(col), '0') FROM tbl WHERE FALSE`;
Moreover, the nullability checks for WHERE clauses have been enhanced.
// ❌ Previously, SafeQL annotated a nullable column as null, // even though it was checked for nullability: const result = await sql<{ text_nullable: string | null }>` SELECT text_nullable FROM tbl WHERE text_nullable IS NOT NULL `; // ✅ Now, SafeQL accurately annotates the column as non-nullable const result = await sql<{ text_nullable: string }>` SELECT text_nullable FROM tbl WHERE text_nullable IS NOT NULL `;
Patch Changes
@ts-safeql/eslint-plugin@1.1.4
Patch Changes
- ba02059: Add support for select statements with the following expression (type | null)[]
@ts-safeql/eslint-plugin@1.1.3
Patch Changes
- 2e681c4: fixed type check when using derived type as override type
@ts-safeql/test-utils@0.0.11
Patch Changes
- Updated dependencies [c5b4af1]
- @ts-safeql/shared@0.1.1
@ts-safeql/shared@0.1.1
Patch Changes
- c5b4af1: add support for custom type overrides
@ts-safeql/generate@0.1.1
@ts-safeql/eslint-plugin@1.1.2
@ts-safeql/eslint-plugin@1.1.1
Patch Changes
- 6c15534: fixed an issue where INSERT INTO with a null value was invalid
@ts-safeql/test-utils@0.0.10
Patch Changes
- Updated dependencies [30965b2]
- @ts-safeql/shared@0.1.0