Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc7fe77

Browse files
committed
fixup null
1 parent8da3601 commitdc7fe77

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

‎coderd/database/models.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/querier.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go‎

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/roles.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ WHERE
99
-- To do this manually in SQL, you can construct an array and cast it:
1010
-- cast(ARRAY[('customrole','ece79dac-926e-44ca-9790-2ff7c5eb6e0c')] AS name_organization_pair[])
1111
AND CASE WHEN array_length(@lookup_roles :: name_organization_pair[],1)>0 THEN
12-
(name, organization_id)= ANY (@lookup_roles::name_organization_pair[])
12+
-- Using 'coalesce' to avoid troubles with null literals being an empty string.
13+
(name, coalesce(organization_id,'00000000-0000-0000-0000-000000000000' ::uuid))= ANY (@lookup_roles::name_organization_pair[])
1314
ELSE true
1415
END
1516
-- This allows fetching all roles, or just site wide roles

‎coderd/database/types.go‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,13 @@ func (*NameOrganizationPair) Scan(_ interface{}) error {
160160
// shell.
161161
//
162162
//SELECT ('customrole'::text,'ece79dac-926e-44ca-9790-2ff7c5eb6e0c'::uuid);
163-
//To see 'null' option
164-
//SELECT ('customrole',null);
163+
//To see 'null' option. Using the nil uuid as null to avoid empty string literals for null.
164+
//SELECT ('customrole',00000000-0000-0000-0000-000000000000);
165165
//
166166
// This value is usually used as an array, NameOrganizationPair[]. You can see
167167
// what that literal is as well, with proper quoting.
168168
//
169169
//SELECT ARRAY[('customrole'::text,'ece79dac-926e-44ca-9790-2ff7c5eb6e0c'::uuid)];
170170
func (aNameOrganizationPair)Value() (driver.Value,error) {
171-
ifa.OrganizationID==uuid.Nil {
172-
returnfmt.Sprintf(`('%s',)`,a.Name),nil
173-
}
174-
175171
returnfmt.Sprintf(`(%s,%s)`,a.Name,a.OrganizationID.String()),nil
176172
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp