Sample Header Ad - 728x90

Use default value instead of inserted null

3 votes
1 answer
10555 views
I have a table definition in Postgres that use now() for timestamp and current_user() for auditing. date_created date NULL DEFAULT now(), edited_by varchar NULL DEFAULT "current_user"(), The problem is that the server produces queries with explicit null values if not given other instructions. I have no way of changing the query being sent from the server to pg. INSERT INTO test_table (notes, date, edited_by) VALUES('test', null, null); Is there a way to still use these default values somehow? Or is the solution to write a trigger function to solve it?
Asked by geogrow (384 rep)
Mar 1, 2022, 11:55 AM
Last activity: Feb 6, 2023, 08:05 AM