diff --git a/server/src/infra/sql/access.repository.sql b/server/src/infra/sql/access.repository.sql index f2ed3f9a38..638be9f90b 100644 --- a/server/src/infra/sql/access.repository.sql +++ b/server/src/infra/sql/access.repository.sql @@ -7,8 +7,8 @@ FROM "activity" "ActivityEntity" WHERE ( - "ActivityEntity"."id" IN ($1) - AND "ActivityEntity"."userId" = $2 + ("ActivityEntity"."id" IN ($1)) + AND ("ActivityEntity"."userId" = $2) ) -- AccessRepository.activity.checkAlbumOwnerAccess @@ -22,8 +22,14 @@ FROM ) WHERE ( - "ActivityEntity"."id" IN ($1) - AND "ActivityEntity__ActivityEntity_album"."ownerId" = $2 + ("ActivityEntity"."id" IN ($1)) + AND ( + ( + ( + "ActivityEntity__ActivityEntity_album"."ownerId" = $2 + ) + ) + ) ) -- AccessRepository.activity.checkCreateAccess @@ -53,8 +59,8 @@ FROM WHERE ( ( - "AlbumEntity"."id" IN ($1) - AND "AlbumEntity"."ownerId" = $2 + ("AlbumEntity"."id" IN ($1)) + AND ("AlbumEntity"."ownerId" = $2) ) ) AND ("AlbumEntity"."deletedAt" IS NULL) @@ -72,8 +78,12 @@ FROM WHERE ( ( - "AlbumEntity"."id" IN ($1) - AND "AlbumEntity__AlbumEntity_sharedUsers"."id" = $2 + ("AlbumEntity"."id" IN ($1)) + AND ( + ( + ("AlbumEntity__AlbumEntity_sharedUsers"."id" = $2) + ) + ) ) ) AND ("AlbumEntity"."deletedAt" IS NULL) @@ -86,8 +96,8 @@ FROM "shared_links" "SharedLinkEntity" WHERE ( - "SharedLinkEntity"."id" = $1 - AND "SharedLinkEntity"."albumId" IN ($2) + ("SharedLinkEntity"."id" = $1) + AND ("SharedLinkEntity"."albumId" IN ($2)) ) -- AccessRepository.asset.checkAlbumAccess @@ -119,8 +129,8 @@ FROM "assets" "AssetEntity" WHERE ( - "AssetEntity"."id" IN ($1) - AND "AssetEntity"."ownerId" = $2 + ("AssetEntity"."id" IN ($1)) + AND ("AssetEntity"."ownerId" = $2) ) -- AccessRepository.asset.checkPartnerAccess @@ -168,8 +178,8 @@ FROM "user_token" "UserTokenEntity" WHERE ( - "UserTokenEntity"."userId" = $1 - AND "UserTokenEntity"."id" IN ($2) + ("UserTokenEntity"."userId" = $1) + AND ("UserTokenEntity"."id" IN ($2)) ) -- AccessRepository.library.checkOwnerAccess @@ -180,8 +190,8 @@ FROM WHERE ( ( - "LibraryEntity"."id" IN ($1) - AND "LibraryEntity"."ownerId" = $2 + ("LibraryEntity"."id" IN ($1)) + AND ("LibraryEntity"."ownerId" = $2) ) ) AND ("LibraryEntity"."deletedAt" IS NULL) @@ -203,8 +213,8 @@ FROM "person" "PersonEntity" WHERE ( - "PersonEntity"."id" IN ($1) - AND "PersonEntity"."ownerId" = $2 + ("PersonEntity"."id" IN ($1)) + AND ("PersonEntity"."ownerId" = $2) ) -- AccessRepository.person.checkFaceOwnerAccess @@ -218,8 +228,14 @@ FROM ) WHERE ( - "AssetFaceEntity"."id" IN ($1) - AND "AssetFaceEntity__AssetFaceEntity_asset"."ownerId" = $2 + ("AssetFaceEntity"."id" IN ($1)) + AND ( + ( + ( + "AssetFaceEntity__AssetFaceEntity_asset"."ownerId" = $2 + ) + ) + ) ) -- AccessRepository.partner.checkUpdateAccess diff --git a/server/src/infra/sql/album.repository.sql b/server/src/infra/sql/album.repository.sql index 36e6c8be1b..3997dd1a22 100644 --- a/server/src/infra/sql/album.repository.sql +++ b/server/src/infra/sql/album.repository.sql @@ -70,7 +70,7 @@ FROM ) LEFT JOIN "shared_links" "AlbumEntity__AlbumEntity_sharedLinks" ON "AlbumEntity__AlbumEntity_sharedLinks"."albumId" = "AlbumEntity"."id" WHERE - (("AlbumEntity"."id" = $1)) + ((("AlbumEntity"."id" = $1))) AND ("AlbumEntity"."deletedAt" IS NULL) ) "distinctAlias" ORDER BY @@ -131,7 +131,7 @@ FROM "AlbumEntity__AlbumEntity_sharedUsers"."deletedAt" IS NULL ) WHERE - (("AlbumEntity"."id" IN ($1))) + ((("AlbumEntity"."id" IN ($1)))) AND ("AlbumEntity"."deletedAt" IS NULL) -- AlbumRepository.getByAssetId @@ -195,12 +195,20 @@ WHERE ( ( ( - "AlbumEntity"."ownerId" = $1 - AND "AlbumEntity__AlbumEntity_assets"."id" = $2 + ( + ("AlbumEntity"."ownerId" = $1) + AND ((("AlbumEntity__AlbumEntity_assets"."id" = $2))) + ) ) OR ( - "AlbumEntity__AlbumEntity_sharedUsers"."id" = $3 - AND "AlbumEntity__AlbumEntity_assets"."id" = $4 + ( + ( + ( + ("AlbumEntity__AlbumEntity_sharedUsers"."id" = $3) + ) + ) + AND ((("AlbumEntity__AlbumEntity_assets"."id" = $4))) + ) ) ) ) @@ -320,7 +328,7 @@ FROM "AlbumEntity__AlbumEntity_owner"."deletedAt" IS NULL ) WHERE - (("AlbumEntity"."ownerId" = $1)) + ((("AlbumEntity"."ownerId" = $1))) AND ("AlbumEntity"."deletedAt" IS NULL) ORDER BY "AlbumEntity"."createdAt" DESC @@ -393,14 +401,38 @@ FROM WHERE ( ( - ("AlbumEntity__AlbumEntity_sharedUsers"."id" = $1) - OR ( - "AlbumEntity__AlbumEntity_sharedLinks"."userId" = $2 + ( + ( + ( + ( + ("AlbumEntity__AlbumEntity_sharedUsers"."id" = $1) + ) + ) + ) ) OR ( - "AlbumEntity"."ownerId" = $3 - AND NOT ( - "AlbumEntity__AlbumEntity_sharedUsers"."id" IS NULL + ( + ( + ( + ( + "AlbumEntity__AlbumEntity_sharedLinks"."userId" = $2 + ) + ) + ) + ) + ) + OR ( + ( + ("AlbumEntity"."ownerId" = $3) + AND ( + ( + ( + NOT ( + "AlbumEntity__AlbumEntity_sharedUsers"."id" IS NULL + ) + ) + ) + ) ) ) ) @@ -477,9 +509,21 @@ FROM WHERE ( ( - "AlbumEntity"."ownerId" = $1 - AND "AlbumEntity__AlbumEntity_sharedUsers"."id" IS NULL - AND "AlbumEntity__AlbumEntity_sharedLinks"."id" IS NULL + ("AlbumEntity"."ownerId" = $1) + AND ( + ( + ( + "AlbumEntity__AlbumEntity_sharedUsers"."id" IS NULL + ) + ) + ) + AND ( + ( + ( + "AlbumEntity__AlbumEntity_sharedLinks"."id" IS NULL + ) + ) + ) ) ) AND ("AlbumEntity"."deletedAt" IS NULL) @@ -573,8 +617,8 @@ WHERE WHERE ( ( - "AlbumEntity"."id" = $1 - AND "AlbumEntity__AlbumEntity_assets"."id" = $2 + ("AlbumEntity"."id" = $1) + AND ((("AlbumEntity__AlbumEntity_assets"."id" = $2))) ) ) AND ("AlbumEntity"."deletedAt" IS NULL) diff --git a/server/src/infra/sql/api.key.repository.sql b/server/src/infra/sql/api.key.repository.sql index c210ec3bf4..3f6b207ce1 100644 --- a/server/src/infra/sql/api.key.repository.sql +++ b/server/src/infra/sql/api.key.repository.sql @@ -31,7 +31,7 @@ FROM "APIKeyEntity__APIKeyEntity_user"."deletedAt" IS NULL ) WHERE - ("APIKeyEntity"."key" = $1) + (("APIKeyEntity"."key" = $1)) ) "distinctAlias" ORDER BY "APIKeyEntity_id" ASC @@ -49,8 +49,8 @@ FROM "api_keys" "APIKeyEntity" WHERE ( - "APIKeyEntity"."userId" = $1 - AND "APIKeyEntity"."id" = $2 + ("APIKeyEntity"."userId" = $1) + AND ("APIKeyEntity"."id" = $2) ) LIMIT 1 @@ -65,6 +65,6 @@ SELECT FROM "api_keys" "APIKeyEntity" WHERE - ("APIKeyEntity"."userId" = $1) + (("APIKeyEntity"."userId" = $1)) ORDER BY "APIKeyEntity"."createdAt" DESC diff --git a/server/src/infra/sql/asset.repository.sql b/server/src/infra/sql/asset.repository.sql index 0424aba672..e5cf6771fd 100644 --- a/server/src/infra/sql/asset.repository.sql +++ b/server/src/infra/sql/asset.repository.sql @@ -65,11 +65,11 @@ FROM WHERE ( ( - "AssetEntity"."ownerId" = $1 - AND "AssetEntity"."isVisible" = $2 - AND "AssetEntity"."isArchived" = $3 - AND NOT ("AssetEntity"."resizePath" IS NULL) - AND "AssetEntity"."fileCreatedAt" BETWEEN $4 AND $5 + ("AssetEntity"."ownerId" = $1) + AND ("AssetEntity"."isVisible" = $2) + AND ("AssetEntity"."isArchived" = $3) + AND (NOT ("AssetEntity"."resizePath" IS NULL)) + AND ("AssetEntity"."fileCreatedAt" BETWEEN $4 AND $5) ) ) AND ("AssetEntity"."deletedAt" IS NULL) @@ -286,7 +286,7 @@ FROM LEFT JOIN "asset_stack" "AssetEntity__AssetEntity_stack" ON "AssetEntity__AssetEntity_stack"."id" = "AssetEntity"."stackId" LEFT JOIN "assets" "bd93d5747511a4dad4923546c51365bf1a803774" ON "bd93d5747511a4dad4923546c51365bf1a803774"."stackId" = "AssetEntity__AssetEntity_stack"."id" WHERE - ("AssetEntity"."id" IN ($1)) + (("AssetEntity"."id" IN ($1))) -- AssetRepository.deleteAll DELETE FROM "assets" @@ -331,7 +331,13 @@ FROM "AssetEntity__AssetEntity_library"."deletedAt" IS NULL ) WHERE - (("AssetEntity__AssetEntity_library"."id" IN ($1))) + ( + ( + ( + (("AssetEntity__AssetEntity_library"."id" IN ($1))) + ) + ) + ) AND ("AssetEntity"."deletedAt" IS NULL) -- AssetRepository.getByLibraryIdAndOriginalPath @@ -378,8 +384,8 @@ FROM WHERE ( ( - "AssetEntity__AssetEntity_library"."id" = $1 - AND "AssetEntity"."originalPath" = $2 + ((("AssetEntity__AssetEntity_library"."id" = $1))) + AND ("AssetEntity"."originalPath" = $2) ) ) AND ("AssetEntity"."deletedAt" IS NULL) @@ -446,9 +452,9 @@ FROM "assets" "AssetEntity" WHERE ( - "AssetEntity"."ownerId" = $1 - AND "AssetEntity"."deviceId" = $2 - AND "AssetEntity"."isVisible" = $3 + ("AssetEntity"."ownerId" = $1) + AND ("AssetEntity"."deviceId" = $2) + AND ("AssetEntity"."isVisible" = $3) ) -- AssetRepository.getById @@ -485,7 +491,7 @@ SELECT FROM "assets" "AssetEntity" WHERE - ("AssetEntity"."id" = $1) + (("AssetEntity"."id" = $1)) LIMIT 1 @@ -533,8 +539,8 @@ FROM WHERE ( ( - "AssetEntity"."ownerId" = $1 - AND "AssetEntity"."checksum" = $2 + ("AssetEntity"."ownerId" = $1) + AND ("AssetEntity"."checksum" = $2) ) ) AND ("AssetEntity"."deletedAt" IS NULL) @@ -578,12 +584,16 @@ WHERE ( ( ( - "AssetEntity"."sidecarPath" IS NULL - AND "AssetEntity"."isVisible" = $1 + ( + ("AssetEntity"."sidecarPath" IS NULL) + AND ("AssetEntity"."isVisible" = $1) + ) ) OR ( - "AssetEntity"."sidecarPath" = $2 - AND "AssetEntity"."isVisible" = $3 + ( + ("AssetEntity"."sidecarPath" = $2) + AND ("AssetEntity"."isVisible" = $3) + ) ) ) ) diff --git a/server/src/infra/sql/library.repository.sql b/server/src/infra/sql/library.repository.sql index 94ba7b3dd9..433ab6fbac 100644 --- a/server/src/infra/sql/library.repository.sql +++ b/server/src/infra/sql/library.repository.sql @@ -39,7 +39,7 @@ FROM "LibraryEntity__LibraryEntity_owner"."deletedAt" IS NULL ) WHERE - (("LibraryEntity"."id" = $1)) + ((("LibraryEntity"."id" = $1))) AND ("LibraryEntity"."deletedAt" IS NULL) ) "distinctAlias" ORDER BY @@ -62,7 +62,7 @@ WHERE FROM "libraries" "LibraryEntity" WHERE - (("LibraryEntity"."name" = $1)) + ((("LibraryEntity"."name" = $1))) AND ("LibraryEntity"."deletedAt" IS NULL) ) LIMIT @@ -74,7 +74,7 @@ SELECT FROM "libraries" "LibraryEntity" WHERE - (("LibraryEntity"."ownerId" = $1)) + ((("LibraryEntity"."ownerId" = $1))) AND ("LibraryEntity"."deletedAt" IS NULL) -- LibraryRepository.getDefaultUploadLibrary @@ -95,8 +95,8 @@ FROM WHERE ( ( - "LibraryEntity"."ownerId" = $1 - AND "LibraryEntity"."type" = $2 + ("LibraryEntity"."ownerId" = $1) + AND ("LibraryEntity"."type" = $2) ) ) AND ("LibraryEntity"."deletedAt" IS NULL) @@ -113,8 +113,8 @@ FROM WHERE ( ( - "LibraryEntity"."ownerId" = $1 - AND "LibraryEntity"."type" = $2 + ("LibraryEntity"."ownerId" = $1) + AND ("LibraryEntity"."type" = $2) ) ) AND ("LibraryEntity"."deletedAt" IS NULL) @@ -156,8 +156,8 @@ FROM WHERE ( ( - "LibraryEntity"."ownerId" = $1 - AND "LibraryEntity"."isVisible" = $2 + ("LibraryEntity"."ownerId" = $1) + AND ("LibraryEntity"."isVisible" = $2) ) ) AND ("LibraryEntity"."deletedAt" IS NULL) @@ -236,8 +236,8 @@ FROM LEFT JOIN "users" "LibraryEntity__LibraryEntity_owner" ON "LibraryEntity__LibraryEntity_owner"."id" = "LibraryEntity"."ownerId" WHERE ( - "LibraryEntity"."isVisible" = $1 - AND NOT ("LibraryEntity"."deletedAt" IS NULL) + ("LibraryEntity"."isVisible" = $1) + AND (NOT ("LibraryEntity"."deletedAt" IS NULL)) ) ORDER BY "LibraryEntity"."createdAt" ASC diff --git a/server/src/infra/sql/move.repository.sql b/server/src/infra/sql/move.repository.sql index b83175bd3f..3ce8c0ccdd 100644 --- a/server/src/infra/sql/move.repository.sql +++ b/server/src/infra/sql/move.repository.sql @@ -11,8 +11,8 @@ FROM "move_history" "MoveEntity" WHERE ( - "MoveEntity"."entityId" = $1 - AND "MoveEntity"."pathType" = $2 + ("MoveEntity"."entityId" = $1) + AND ("MoveEntity"."pathType" = $2) ) LIMIT 1 diff --git a/server/src/infra/sql/person.repository.sql b/server/src/infra/sql/person.repository.sql index 781e68d9ae..bd4a523e86 100644 --- a/server/src/infra/sql/person.repository.sql +++ b/server/src/infra/sql/person.repository.sql @@ -83,7 +83,7 @@ FROM "asset_faces" "AssetFaceEntity" LEFT JOIN "person" "AssetFaceEntity__AssetFaceEntity_person" ON "AssetFaceEntity__AssetFaceEntity_person"."id" = "AssetFaceEntity"."personId" WHERE - ("AssetFaceEntity"."assetId" = $1) + (("AssetFaceEntity"."assetId" = $1)) -- PersonRepository.getFaceById SELECT DISTINCT @@ -113,7 +113,7 @@ FROM "asset_faces" "AssetFaceEntity" LEFT JOIN "person" "AssetFaceEntity__AssetFaceEntity_person" ON "AssetFaceEntity__AssetFaceEntity_person"."id" = "AssetFaceEntity"."personId" WHERE - ("AssetFaceEntity"."id" = $1) + (("AssetFaceEntity"."id" = $1)) ) "distinctAlias" ORDER BY "AssetFaceEntity_id" ASC @@ -181,7 +181,7 @@ FROM "AssetFaceEntity__AssetFaceEntity_asset"."deletedAt" IS NULL ) WHERE - ("AssetFaceEntity"."id" = $1) + (("AssetFaceEntity"."id" = $1)) ) "distinctAlias" ORDER BY "AssetFaceEntity_id" ASC @@ -325,9 +325,13 @@ FROM WHERE ( ( - "AssetEntity__AssetEntity_faces"."personId" = $1 - AND "AssetEntity"."isVisible" = $2 - AND "AssetEntity"."isArchived" = $3 + ( + ( + ("AssetEntity__AssetEntity_faces"."personId" = $1) + ) + ) + AND ("AssetEntity"."isVisible" = $2) + AND ("AssetEntity"."isArchived" = $3) ) ) AND ("AssetEntity"."deletedAt" IS NULL) @@ -395,8 +399,10 @@ FROM WHERE ( ( - "AssetFaceEntity"."assetId" = $1 - AND "AssetFaceEntity"."personId" = $2 + ( + ("AssetFaceEntity"."assetId" = $1) + AND ("AssetFaceEntity"."personId" = $2) + ) ) ) @@ -414,6 +420,6 @@ SELECT FROM "asset_faces" "AssetFaceEntity" WHERE - ("AssetFaceEntity"."personId" = $1) + (("AssetFaceEntity"."personId" = $1)) LIMIT 1 diff --git a/server/src/infra/sql/shared.link.repository.sql b/server/src/infra/sql/shared.link.repository.sql index 6d6c0376ac..6cac1c44fc 100644 --- a/server/src/infra/sql/shared.link.repository.sql +++ b/server/src/infra/sql/shared.link.repository.sql @@ -183,8 +183,8 @@ FROM ) WHERE ( - "SharedLinkEntity"."id" = $1 - AND "SharedLinkEntity"."userId" = $2 + ("SharedLinkEntity"."id" = $1) + AND ("SharedLinkEntity"."userId" = $2) ) ) "distinctAlias" ORDER BY @@ -278,7 +278,7 @@ FROM "6d7fd45329a05fd86b3dbcacde87fe76e33a422d"."deletedAt" IS NULL ) WHERE - ("SharedLinkEntity"."userId" = $1) + (("SharedLinkEntity"."userId" = $1)) ORDER BY "SharedLinkEntity"."createdAt" DESC @@ -322,7 +322,7 @@ FROM "SharedLinkEntity__SharedLinkEntity_user"."deletedAt" IS NULL ) WHERE - ("SharedLinkEntity"."key" = $1) + (("SharedLinkEntity"."key" = $1)) ) "distinctAlias" ORDER BY "SharedLinkEntity_id" ASC diff --git a/server/src/infra/sql/user.repository.sql b/server/src/infra/sql/user.repository.sql index 390a26cbdb..e4c7d3a314 100644 --- a/server/src/infra/sql/user.repository.sql +++ b/server/src/infra/sql/user.repository.sql @@ -20,7 +20,7 @@ SELECT FROM "users" "UserEntity" WHERE - (("UserEntity"."isAdmin" = $1)) + ((("UserEntity"."isAdmin" = $1))) AND ("UserEntity"."deletedAt" IS NULL) LIMIT 1 @@ -40,7 +40,7 @@ WHERE FROM "users" "UserEntity" WHERE - (("UserEntity"."isAdmin" = $1)) + ((("UserEntity"."isAdmin" = $1))) AND ("UserEntity"."deletedAt" IS NULL) ) LIMIT @@ -89,7 +89,7 @@ SELECT FROM "users" "UserEntity" WHERE - (("UserEntity"."storageLabel" = $1)) + ((("UserEntity"."storageLabel" = $1))) AND ("UserEntity"."deletedAt" IS NULL) LIMIT 1 @@ -114,7 +114,7 @@ SELECT FROM "users" "UserEntity" WHERE - (("UserEntity"."oauthId" = $1)) + ((("UserEntity"."oauthId" = $1))) AND ("UserEntity"."deletedAt" IS NULL) LIMIT 1 diff --git a/server/src/infra/sql/user.token.repository.sql b/server/src/infra/sql/user.token.repository.sql index 4c9ff32163..b51e53106e 100644 --- a/server/src/infra/sql/user.token.repository.sql +++ b/server/src/infra/sql/user.token.repository.sql @@ -34,7 +34,7 @@ FROM "UserTokenEntity__UserTokenEntity_user"."deletedAt" IS NULL ) WHERE - ("UserTokenEntity"."token" = $1) + (("UserTokenEntity"."token" = $1)) ) "distinctAlias" ORDER BY "UserTokenEntity_id" ASC