chore: no sql generation for queries with side effects (#18301)

no sql generation for queries with side effects
This commit is contained in:
Mert 2025-05-14 23:34:22 -04:00 committed by GitHub
parent 6a4d21205f
commit 709a7b70aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 48 additions and 167 deletions

View file

@ -432,3 +432,34 @@ where
and "assets"."updatedAt" > $3
limit
$4
-- AssetRepository.detectOfflineExternalAssets
update "assets"
set
"isOffline" = $1,
"deletedAt" = $2
where
"isOffline" = $3
and "isExternal" = $4
and "libraryId" = $5::uuid
and (
not "originalPath" like $6
or "originalPath" like $7
)
-- AssetRepository.filterNewExternalAssetPaths
select
"path"
from
unnest(array[$1]::text[]) as "path"
where
not exists (
select
"originalPath"
from
"assets"
where
"assets"."originalPath" = "path"
and "libraryId" = $2::uuid
and "isExternal" = $3
)

View file

@ -14,8 +14,3 @@ order by
"audit"."entityId" desc,
"audit"."entityType" desc,
"audit"."createdAt" desc
-- AuditRepository.removeBefore
delete from "audit"
where
"createdAt" < $1

View file

@ -1,11 +1,5 @@
-- NOTE: This file is auto generated by ./sql-generator
-- MemoryRepository.cleanup
delete from "memories"
where
"createdAt" < $1
and "isSaved" = $2
-- MemoryRepository.search
select
"memories".*,

View file

@ -16,19 +16,6 @@ where
returning
*
-- MoveRepository.cleanMoveHistory
delete from "move_history"
where
"move_history"."entityId" not in (
select
"id"
from
"assets"
where
"assets"."id" = "move_history"."entityId"
)
and "move_history"."pathType" = 'original'
-- MoveRepository.cleanMoveHistorySingle
delete from "move_history"
where

View file

@ -1,23 +1,5 @@
-- NOTE: This file is auto generated by ./sql-generator
-- NotificationRepository.cleanup
delete from "notifications"
where
(
(
"deletedAt" is not null
and "deletedAt" < $1
)
or (
"readAt" > $2
and "createdAt" < $3
)
or (
"readAt" = $4
and "createdAt" < $5
)
)
-- NotificationRepository.search
select
"id",

View file

@ -100,50 +100,6 @@ where
"sharedWithId" = $1
and "sharedById" = $2
-- PartnerRepository.create
insert into
"partners" ("sharedWithId", "sharedById")
values
($1, $2)
returning
*,
(
select
to_json(obj)
from
(
select
"id",
"name",
"email",
"avatarColor",
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedBy"
where
"sharedBy"."id" = "partners"."sharedById"
) as obj
) as "sharedBy",
(
select
to_json(obj)
from
(
select
"id",
"name",
"email",
"avatarColor",
"profileImagePath",
"profileChangedAt"
from
"users" as "sharedWith"
where
"sharedWith"."id" = "partners"."sharedWithId"
) as obj
) as "sharedWith"
-- PartnerRepository.update
update "partners"
set

View file

@ -7,22 +7,10 @@ set
where
"asset_faces"."personId" = $2
-- PersonRepository.unassignFaces
update "asset_faces"
set
"personId" = $1
where
"asset_faces"."sourceType" = $2
-- PersonRepository.delete
delete from "person"
where
"person"."id" in $1
-- PersonRepository.deleteFaces
delete from "asset_faces"
where
"asset_faces"."sourceType" = $1
"person"."id" in ($1)
-- PersonRepository.getAllWithoutFaces
select
@ -216,21 +204,6 @@ where
"person"."ownerId" = $3
and "asset_faces"."deletedAt" is null
-- PersonRepository.refreshFaces
with
"added_embeddings" as (
insert into
"face_search" ("faceId", "embedding")
values
($1, $2)
)
select
from
(
select
1
) as "dummy"
-- PersonRepository.getFacesByIds
select
"asset_faces".*,

View file

@ -8,15 +8,6 @@ from
where
"key" = $1
-- SystemMetadataRepository.set
insert into
"system_metadata" ("key", "value")
values
($1, $2)
on conflict ("key") do update
set
"value" = $3
-- SystemMetadataRepository.delete
delete from "system_metadata"
where

View file

@ -58,7 +58,7 @@ from
where
"userId" = $1
order by
"value" asc
"value"
-- TagRepository.create
insert into
@ -94,6 +94,15 @@ where
"tagsId" = $1
and "assetsId" in ($2)
-- TagRepository.upsertAssetIds
insert into
"tag_asset" ("assetId", "tagsIds")
values
($1, $2)
on conflict do nothing
returning
*
-- TagRepository.replaceAssetTags
begin
delete from "tag_asset"
@ -107,17 +116,3 @@ on conflict do nothing
returning
*
rollback
-- TagRepository.deleteEmptyTags
begin
select
"tags"."id",
count("assets"."id") as "count"
from
"assets"
inner join "tag_asset" on "tag_asset"."assetsId" = "assets"."id"
inner join "tags_closure" on "tags_closure"."id_descendant" = "tag_asset"."tagsId"
inner join "tags" on "tags"."id" = "tags_closure"."id_descendant"
group by
"tags"."id"
commit

View file

@ -15,11 +15,3 @@ from
"version_history"
order by
"createdAt" desc
-- VersionHistoryRepository.create
insert into
"version_history" ("version")
values
($1)
returning
*