Skip to content

Can't used inline PSQL functions as insert/update values #13

@pozhega

Description

@pozhega

Problem example

For given table:

CREATE TABLE weekly_survey_requests(
  created_at TIMESTAMP DEFAULT NOW(),
  expired_at TIMESTAMP,
  id uuid NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
  question_id uuid REFERENCES questions (id) ON DELETE CASCADE,
  responded_at TIMESTAMP,
  updated_at TIMESTAMP DEFAULT NOW(),
  user_id uuid REFERENCES users (id) ON DELETE CASCADE,
  user_sumission_id uuid REFERENCES users_submissions (id) ON DELETE SET NULL
);

I want to update existing record with a current timestamp using SQL now() function, but when I execute this query:

(defn- expire-active-weekly-question-requests [{:keys [env]}]
  (penkala/update! env
                   (-> (r/->updatable (:weekly-survey-requests env))
                       (r/where [:is-not-null :expired-at])
                       (r/where [:is-null :responded-at]))
                   {:expired-at [:now]}))

i get the following error:

“Column \“expired_at\” is of type timestamp without time zone but expression is of type jsonb”}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions