-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find a good solution for update_at on the postgresql backend #135
Comments
Hey @Jerben 🙂 I was looking into Sihl (really nice project!!) and stumbled upon this issue, so I thought I'd share this piece of code that I use for CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = now();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_users_updated_at"
BEFORE UPDATE ON "public"."users"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); This will set the value of Not sure this is what you meant, but I hope it helps 😄 |
Hey @tmattio, thanks a lot for the kind words and the nice input! 🙂 Once the MariaDB driver supports non-prepared statements, this will be most likely the solution. |
Good to know, thanks for the link! |
@tmattio I just realized this is only an issue for Postgres 🙂 Last time I checked the issue for the MariaDB driver doesn't really exist for the Postgres driver, so this works! 👍 |
For now we are doing that on application level so it is repo independent. |
No description provided.
The text was updated successfully, but these errors were encountered: