DT
Drizzle Team•10mo ago
frankscp

How to check if a column of type uuid has a value missing without using sql

Hello, I have a table that references other via foreign key. Both Ids are of type UUID. How can I check if the UUID's value is null using the javascript library? I was expecting 'eq(table1.table2Id, null)' to work, and it actually does at runtime, but I get the following typescript error:
No overload matches this call.
Overload 1 of 3, '(left: PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>, right: string | SQLWrapper): SQL<...>', gave the following error.
Argument of type 'null' is not assignable to parameter of type 'string | SQLWrapper'.
Overload 2 of 3, '(left: Aliased<null>, right: SQLWrapper | null): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<null>'.
Type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is missing the following properties from type 'Aliased<null>': sql, fieldAlias
Overload 3 of 3, '(left: never, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'never'.
No overload matches this call.
Overload 1 of 3, '(left: PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>, right: string | SQLWrapper): SQL<...>', gave the following error.
Argument of type 'null' is not assignable to parameter of type 'string | SQLWrapper'.
Overload 2 of 3, '(left: Aliased<null>, right: SQLWrapper | null): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<null>'.
Type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is missing the following properties from type 'Aliased<null>': sql, fieldAlias
Overload 3 of 3, '(left: never, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "table2_id"; tableName: "table1"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'never'.
2 Replies
Angelelz
Angelelz•10mo ago
In databases this is supposed to be true: null !== null The correct way to check if a column is null is with the isNull and isNotNull helper functions from drizzle
frankscp
frankscp•10mo ago
Perfect, thank you! 🙂
Want results from more Discord servers?
Add your server