Replies: 1 comment
-
Hi! Yes, that's how SQL works. NULL and the empty string are distinct and need to be handled separately. You can use CASE... WHEN to insert a default value instead of the empty string INSERT INTO users (name)
VALUES (
CASE $name WHEN '' THEN 'anonymous' ELSE $name END
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Submitting a form with a field with no content doesn't trigger the
AS DEFAULT
for theNOT NULL
column but instead gives a "NOT NULL CONSTRAINT" error.PostgreSQL 15
SQLPage 0.37.1
Beta Was this translation helpful? Give feedback.
All reactions