-- NOTE: This file is auto generated by ./sql-generator

-- ViewRepository.getAssetsByOriginalPath
SELECT
  "asset"."id" AS "asset_id",
  "asset"."deviceAssetId" AS "asset_deviceAssetId",
  "asset"."ownerId" AS "asset_ownerId",
  "asset"."libraryId" AS "asset_libraryId",
  "asset"."deviceId" AS "asset_deviceId",
  "asset"."type" AS "asset_type",
  "asset"."status" AS "asset_status",
  "asset"."originalPath" AS "asset_originalPath",
  "asset"."thumbhash" AS "asset_thumbhash",
  "asset"."encodedVideoPath" AS "asset_encodedVideoPath",
  "asset"."createdAt" AS "asset_createdAt",
  "asset"."updatedAt" AS "asset_updatedAt",
  "asset"."deletedAt" AS "asset_deletedAt",
  "asset"."fileCreatedAt" AS "asset_fileCreatedAt",
  "asset"."localDateTime" AS "asset_localDateTime",
  "asset"."fileModifiedAt" AS "asset_fileModifiedAt",
  "asset"."isFavorite" AS "asset_isFavorite",
  "asset"."isArchived" AS "asset_isArchived",
  "asset"."isExternal" AS "asset_isExternal",
  "asset"."isOffline" AS "asset_isOffline",
  "asset"."checksum" AS "asset_checksum",
  "asset"."duration" AS "asset_duration",
  "asset"."isVisible" AS "asset_isVisible",
  "asset"."livePhotoVideoId" AS "asset_livePhotoVideoId",
  "asset"."originalFileName" AS "asset_originalFileName",
  "asset"."sidecarPath" AS "asset_sidecarPath",
  "asset"."stackId" AS "asset_stackId",
  "asset"."duplicateId" AS "asset_duplicateId",
  "exifInfo"."assetId" AS "exifInfo_assetId",
  "exifInfo"."description" AS "exifInfo_description",
  "exifInfo"."exifImageWidth" AS "exifInfo_exifImageWidth",
  "exifInfo"."exifImageHeight" AS "exifInfo_exifImageHeight",
  "exifInfo"."fileSizeInByte" AS "exifInfo_fileSizeInByte",
  "exifInfo"."orientation" AS "exifInfo_orientation",
  "exifInfo"."dateTimeOriginal" AS "exifInfo_dateTimeOriginal",
  "exifInfo"."modifyDate" AS "exifInfo_modifyDate",
  "exifInfo"."timeZone" AS "exifInfo_timeZone",
  "exifInfo"."latitude" AS "exifInfo_latitude",
  "exifInfo"."longitude" AS "exifInfo_longitude",
  "exifInfo"."projectionType" AS "exifInfo_projectionType",
  "exifInfo"."city" AS "exifInfo_city",
  "exifInfo"."livePhotoCID" AS "exifInfo_livePhotoCID",
  "exifInfo"."autoStackId" AS "exifInfo_autoStackId",
  "exifInfo"."state" AS "exifInfo_state",
  "exifInfo"."country" AS "exifInfo_country",
  "exifInfo"."make" AS "exifInfo_make",
  "exifInfo"."model" AS "exifInfo_model",
  "exifInfo"."lensModel" AS "exifInfo_lensModel",
  "exifInfo"."fNumber" AS "exifInfo_fNumber",
  "exifInfo"."focalLength" AS "exifInfo_focalLength",
  "exifInfo"."iso" AS "exifInfo_iso",
  "exifInfo"."exposureTime" AS "exifInfo_exposureTime",
  "exifInfo"."profileDescription" AS "exifInfo_profileDescription",
  "exifInfo"."colorspace" AS "exifInfo_colorspace",
  "exifInfo"."bitsPerSample" AS "exifInfo_bitsPerSample",
  "exifInfo"."rating" AS "exifInfo_rating",
  "exifInfo"."fps" AS "exifInfo_fps"
FROM
  "assets" "asset"
  LEFT JOIN "exif" "exifInfo" ON "exifInfo"."assetId" = "asset"."id"
WHERE
  (
    (
      "asset"."isVisible" = $1
      AND "asset"."isArchived" = $2
      AND "asset"."ownerId" = $3
    )
    AND (
      "asset"."originalPath" LIKE $4
      AND "asset"."originalPath" NOT LIKE $5
    )
  )
  AND ("asset"."deletedAt" IS NULL)
ORDER BY
  regexp_replace("asset"."originalPath", '.*/(.+)', '\1') ASC
