Postgresql:“"ViewShifts"”处或附近的语法错误为什么我在下面的查询中会收到此错误?

Postgresql: syntax error at or near ""ViewShifts"" why do i get this error with the query below?

    await queryInterface.sequelize.query(`
    CREATE OR REPLACE "ViewShifts" AS
    select
      s.id,
      s.facility_id,
      s.assigned_nurse_id,
      case when u.id is not null
        then jsonb_build_object(
          'id', u.id,
          'name', u.name,
          'rating', u.rating,
          'image', u.image->>'src'
        )
        else null
      end as "assignedNurse",
      case when p.id is not null
        then jsonb_build_object(
          'id', p.id,
          'paymentDate', p."paymentDate",
          'isPaymentDateDefault', p."isPaymentDateDefault",
          'status', p.status,
          'type', p.type,
          'netPay', p."netPay",
          'comment', p.comment,
          'reason', p.reason
        )
        else null
      end as payment,
      p.adjustments as "paymentAdjustments",
      s.role,
      s.type,
      s.unit,
      s."unitDescription",
      s.start_time,
      s.end_time,
      s.rate,
      s.net_pay,
      s.qualifications,
      s.description,
      s.status,
      s."prevStatus",
      s."statusUpdatedAt",
      s."breakTime",
      s.review,
      s."isMinPaymentEnabled",
      s."applicantLocationStatus",
      "checkIn".id as "checkInId",
      "checkIn"."selectedTime" as "checkInTime",
      "checkIn"."createdAt" as "checkInCreatedAt",
      "checkOut".id as "checkOutId",
      "checkOut"."selectedTime" as "checkOutTime",
      "checkOut"."createdAt" as "checkOutCreatedAt",
      "checkOut"."rating" as "ratingFromNurse",
      s."applicantCount" as applicants,
      f.id as "facilityId",
      f.name as "facilityName",
      f.short_name as "facilityShortName",
      f.timezone as "facilityTimezone",
      f."segmentId",
      f."segmentName",
      s."createdAt",
      s."updatedAt",
      s."deletedAt",
      s."cancelledAt"
      s."autoSelectApplicant",
      s."autoSelectApplicantSelected",
      s."autoSelectType",
      from shifts s
      left join facilities f on (s.facility_id = f.id and f."deletedAt" is null)
      left join users u on (s.assigned_nurse_id = u.id)
      left join "CheckEvents" as "checkIn" on (s."actualCheckInId" = "checkIn".id)
      left join "CheckEvents" as "checkOut" on (s."actualCheckOutId" = "checkOut".id)
      left join "Payments" as p on (p."shiftId" = s.id and p.type <> 'other');
    `);

请问“ViewShifts”错误处或附近出现语法错误的原因是什么?任何帮助将不胜感激。

我正在尝试修改现有的 Postgres 视图。我还能怎么办?

请问“ViewShifts”错误处或附近出现语法错误的原因是什么?任何帮助将不胜感激。

我正在尝试修改现有的 Postgres 视图。我还能怎么办?

您的代码中存在一些语法错误

CREATE OR REPLACE VIEW "ViewShifts" AS
select
  s.id,
  s.facility_id,
  s.assigned_nurse_id,
  case when u.id is not null
    then jsonb_build_object(
      'id', u.id,
      'name', u.name,
      'rating', u.rating,
      'image', u.image->>'src'
    )
    else null
  end as "assignedNurse",
  case when p.id is not null
    then jsonb_build_object(
      'id', p.id,
      'paymentDate', p."paymentDate",
      'isPaymentDateDefault', p."isPaymentDateDefault",
      'status', p.status,
      'type', p.type,
      'netPay', p."netPay",
      'comment', p.comment,
      'reason', p.reason
    )
    else null
  end as payment,
  p.adjustments as "paymentAdjustments",
  s.role,
  s.type,
  s.unit,
  s."unitDescription",
  s.start_time,
  s.end_time,
  s.rate,
  s.net_pay,
  s.qualifications,
  s.description,
  s.status,
  s."prevStatus",
  s."statusUpdatedAt",
  s."breakTime",
  s.review,
  s."isMinPaymentEnabled",
  s."applicantLocationStatus",
  "checkIn".id as "checkInId",
  "checkIn"."selectedTime" as "checkInTime",
  "checkIn"."createdAt" as "checkInCreatedAt",
  "checkOut".id as "checkOutId",
  "checkOut"."selectedTime" as "checkOutTime",
  "checkOut"."createdAt" as "checkOutCreatedAt",
  "checkOut"."rating" as "ratingFromNurse",
  s."applicantCount" as applicants,
  f.id as "facilityId",
  f.name as "facilityName",
  f.short_name as "facilityShortName",
  f.timezone as "facilityTimezone",
  f."segmentId",
  f."segmentName",
  s."createdAt",
  s."updatedAt",
  s."deletedAt",
  s."cancelledAt",
  s."autoSelectApplicant",
  s."autoSelectApplicantSelected",
  s."autoSelectType"
  from shifts s
  left join facilities f on (s.facility_id = f.id and f."deletedAt" is null)
  left join users u on (s.assigned_nurse_id = u.id)
  left join "CheckEvents" as "checkIn" on (s."actualCheckInId" = "checkIn".id)
  left join "CheckEvents" as "checkOut" on (s."actualCheckOutId" = "checkOut".id)
  left join "Payments" as p on (p."shiftId" = s.id and p.type <> 'other');