Skip to content

Commit

Permalink
chore: add semicolon to sql queries
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbh committed Feb 16, 2022
1 parent c30a7a2 commit b4ee390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ ALTER TABLE relations
ADD COLUMN namespace_id VARCHAR REFERENCES namespaces (id),
DROP CONSTRAINT IF EXISTS relations_subject_namespace_id_subject_id_role_id_object_na_key;

CREATE UNIQUE INDEX unique_relation_with_ns_id ON relations (subject_namespace_id, subject_id, object_namespace_id, object_id, COALESCE(role_id, ''), COALESCE(namespace_id, ''))
CREATE UNIQUE INDEX unique_relation_with_ns_id ON relations (subject_namespace_id, subject_id, object_namespace_id, object_id, COALESCE(role_id, ''), COALESCE(namespace_id, ''));
12 changes: 6 additions & 6 deletions store/postgres/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
$6
)
ON CONFLICT (subject_namespace_id, subject_id, object_namespace_id, object_id, COALESCE(role_id, ''), COALESCE(namespace_id, '')) DO UPDATE SET subject_namespace_id=$1
RETURNING id, subject_namespace_id, subject_id, object_namespace_id, object_id, role_id, namespace_id, created_at, updated_at`
RETURNING id, subject_namespace_id, subject_id, object_namespace_id, object_id, role_id, namespace_id, created_at, updated_at;`
listRelationQuery = `
SELECT
id,
Expand All @@ -58,7 +58,7 @@ const (
namespace_id,
created_at,
updated_at
FROM relations`
FROM relations;`
getRelationsQuery = `
SELECT
id,
Expand All @@ -71,7 +71,7 @@ const (
created_at,
updated_at
FROM relations
WHERE id = $1`
WHERE id = $1;`
updateRelationQuery = `
UPDATE relations SET
subject_namespace_id = $2,
Expand All @@ -90,7 +90,7 @@ const (
role_id,
namespace_id,
created_at,
updated_at
updated_at;
`
getRelationByFieldsQuery = `
SELECT
Expand All @@ -104,8 +104,8 @@ const (
created_at,
updated_at
FROM relations
WHERE subject_namespace_id=$1 AND subject_id=$2 AND object_namespace_id=$3 AND object_id=$4 AND (role_id IS NULL OR role_id = $5) AND (namespace_id IS NULL OR namespace_id = $6)`
deleteRelationById = `DELETE FROM relations WHERE id = $1`
WHERE subject_namespace_id=$1 AND subject_id=$2 AND object_namespace_id=$3 AND object_id=$4 AND (role_id IS NULL OR role_id = $5) AND (namespace_id IS NULL OR namespace_id = $6);`
deleteRelationById = `DELETE FROM relations WHERE id = $1;`
)

func (s Store) CreateRelation(ctx context.Context, relationToCreate model.Relation) (model.Relation, error) {
Expand Down

0 comments on commit b4ee390

Please sign in to comment.