Hello,

I have the following table defined in a PostgreSQL database:

CREATE TABLE test_table (
  id      SERIAL PRIMARY KEY,
  column1 INTEGER REFERENCES test_table2,
  column2 INTEGER UNIQUE NOT NULL REFERENCES test_table3
);

I have set up MYAPPDB::TestTable with the unique key test_table_column2.
Now in my controller I do that:

$->model(MYAPPDB::TestTable)->update_or_create({
   'column1' => $value1,
   'column2' => $value2
}, {key => 'test_table_column2'}
);

If $value1 is null, I get the following error:

Caught exception in 
MYAPP::Controller::Root->test_action 
"DBIx::Class::ResultSet::update_or_create(): 
Error executing 'UPDATE test_table SET column1 = ? WHERE ( column2 = ? )': 
ERROR:  invalid input syntax for integer: "NULL""

I tried with $value1 = 'NULL', $value1 = '' or undef $value1, but none of them 
worked.

How can I enter a null value in a foreign key column?
Note: it works fine in PostgreSQL when I do UPDATE test_table SET column1 = 
NULL WHERE column2 = $value2.

Can you help me?

Thanks in advance !

Xavier

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to