From 65ffa20ba2927d9e53b2209c848e4d4254edb2ff Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Sun, 6 Nov 2022 16:49:43 -0600 Subject: [PATCH] fix: use correct empty uuids (#4917) --- coderd/database/queries.sql.go | 16 ++++++++-------- coderd/database/queries/auditlogs.sql | 4 ++-- coderd/database/queries/templates.sql | 2 +- coderd/database/queries/templateversions.sql | 2 +- coderd/database/queries/users.sql | 2 +- coderd/database/queries/workspacebuilds.sql | 2 +- coderd/database/queries/workspaces.sql | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/coderd/database/queries.sql.go b/coderd/database/queries.sql.go index 016110e045b05..63732c6fc9ff6 100644 --- a/coderd/database/queries.sql.go +++ b/coderd/database/queries.sql.go @@ -377,7 +377,7 @@ WHERE END -- Filter resource_id AND CASE - WHEN $2 :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN $2 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN resource_id = $2 ELSE true END @@ -468,7 +468,7 @@ WHERE END -- Filter resource_id AND CASE - WHEN $4 :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN $4 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN resource_id = $4 ELSE true END @@ -3152,7 +3152,7 @@ WHERE templates.deleted = $1 -- Filter by organization_id AND CASE - WHEN $2 :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN $2 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN organization_id = $2 ELSE true END @@ -3534,7 +3534,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN $2 :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN $2 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the created_at field, so select all -- rows after the cursor. @@ -4074,7 +4074,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN $2 :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN $2 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the created_at field, so select all -- rows after the cursor. @@ -5312,7 +5312,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN $3 :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN $3 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the build_number field, so select all -- rows after the cursor. @@ -6013,7 +6013,7 @@ WHERE END -- Filter by owner_id AND CASE - WHEN $3 :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN $3 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN owner_id = $3 ELSE true END @@ -6227,7 +6227,7 @@ WHERE END -- Filter by owner_id AND CASE - WHEN $3 :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN $3 :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN owner_id = $3 ELSE true END diff --git a/coderd/database/queries/auditlogs.sql b/coderd/database/queries/auditlogs.sql index b9219b264e670..e80a1d7ba71e0 100644 --- a/coderd/database/queries/auditlogs.sql +++ b/coderd/database/queries/auditlogs.sql @@ -22,7 +22,7 @@ WHERE END -- Filter resource_id AND CASE - WHEN @resource_id :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN @resource_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN resource_id = @resource_id ELSE true END @@ -83,7 +83,7 @@ WHERE END -- Filter resource_id AND CASE - WHEN @resource_id :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN @resource_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN resource_id = @resource_id ELSE true END diff --git a/coderd/database/queries/templates.sql b/coderd/database/queries/templates.sql index 196355ad72404..6eb73af288b81 100644 --- a/coderd/database/queries/templates.sql +++ b/coderd/database/queries/templates.sql @@ -18,7 +18,7 @@ WHERE templates.deleted = @deleted -- Filter by organization_id AND CASE - WHEN @organization_id :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN @organization_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN organization_id = @organization_id ELSE true END diff --git a/coderd/database/queries/templateversions.sql b/coderd/database/queries/templateversions.sql index b92598e5051fc..a84bca465d28f 100644 --- a/coderd/database/queries/templateversions.sql +++ b/coderd/database/queries/templateversions.sql @@ -9,7 +9,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN @after_id :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN @after_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the created_at field, so select all -- rows after the cursor. diff --git a/coderd/database/queries/users.sql b/coderd/database/queries/users.sql index 600578b6c7e65..da6b456e18e20 100644 --- a/coderd/database/queries/users.sql +++ b/coderd/database/queries/users.sql @@ -102,7 +102,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN @after_id :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN @after_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the created_at field, so select all -- rows after the cursor. diff --git a/coderd/database/queries/workspacebuilds.sql b/coderd/database/queries/workspacebuilds.sql index cdb7d0e130f07..ad90109682783 100644 --- a/coderd/database/queries/workspacebuilds.sql +++ b/coderd/database/queries/workspacebuilds.sql @@ -42,7 +42,7 @@ WHERE -- This allows using the last element on a page as effectively a cursor. -- This is an important option for scripts that need to paginate without -- duplicating or missing data. - WHEN @after_id :: uuid != '00000000-00000000-00000000-00000000' THEN ( + WHEN @after_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN ( -- The pagination cursor is the last ID of the previous page. -- The query is ordered by the build_number field, so select all -- rows after the cursor. diff --git a/coderd/database/queries/workspaces.sql b/coderd/database/queries/workspaces.sql index 15e35391f7ed7..09f0431ada2b4 100644 --- a/coderd/database/queries/workspaces.sql +++ b/coderd/database/queries/workspaces.sql @@ -102,7 +102,7 @@ WHERE END -- Filter by owner_id AND CASE - WHEN @owner_id :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN @owner_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN owner_id = @owner_id ELSE true END @@ -240,7 +240,7 @@ WHERE END -- Filter by owner_id AND CASE - WHEN @owner_id :: uuid != '00000000-00000000-00000000-00000000' THEN + WHEN @owner_id :: uuid != '00000000-0000-0000-0000-000000000000'::uuid THEN owner_id = @owner_id ELSE true END