Forum OpenACS Q&A: Response to what if we adjust empty_string_p

Collapse
Posted by Dan Wickstrom on
Don,

I've come across this problem before. I think I even posted it on your site as one of those postgres odities. Here is an example:

Welcome to psql, the PostgreSQL interactive terminal.

Type:  copyright for distribution terms
       h for help with SQL commands
       ? for help on internal slash commands
       g or terminate with semicolon to execute query
       q to quit

acspg=# create table test (
acspg(# x integer);
CREATE
acspg=# insert into test values ('');
INSERT 1541897 1
acspg=# insert into test values (1);
INSERT 1541898 1
acspg=# select * from test;
 x 
---
 0
 1
(2 rows)

acspg=#
It appears that postgres converts an empty string into a zero, which in alot of cases has caused me problems. In the past, I've gone for the oracle behavior by adding triggers to check for empty strings on insert or update and convert them to nulls. I don't know if this is necessarily the best approach to fixing this problem, but at least it gives the same behavior as oracle.