MMBase

Import fails if NODE cannot be NULL

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.7.0
  • Fix Version/s: 1.9.6
  • Component/s: Applications
  • Description:
    Hide
    original bugid: #6090
    The application import attempt to insert NULL values in NODE fields. However, NODE fields can be definied as NOT NULL (depending on the database configuration).
    In those cases, inserting NULL fails. The code should check whether the field can be NULL or not.
    If not, it should enter another value such as -1, or, if using referential integrity, a link to a placeholder object.
    Show
    original bugid: #6090 The application import attempt to insert NULL values in NODE fields. However, NODE fields can be definied as NOT NULL (depending on the database configuration). In those cases, inserting NULL fails. The code should check whether the field can be NULL or not. If not, it should enter another value such as -1, or, if using referential integrity, a link to a placeholder object.

Issue Links

Activity

Hide
Michiel Meeuwissen added a comment - 1970-01-01 00:59
if you store null in a non-nullable field, that is an error.
Show
Michiel Meeuwissen added a comment - 1970-01-01 00:59 if you store null in a non-nullable field, that is an error.
Hide
Pierre van Rooden added a comment - 1970-01-01 00:59
 This is not an option for existing databases, nor does it solve the problem in (future) cases where the database may attempt to store NULL values in other, not-nullable, fields.

IMO the db layer has to deal with this: if a field cannot be NULL, do not store NULL, but an acceptable default value.
Ofcourse what is an acceptable default depends on the field type - for a NODE field -1 may not be useful as a value (but then again, it is only a real problem is the db uses referential integrity for NODE fields, which most now dont).
Show
Pierre van Rooden added a comment - 1970-01-01 00:59  This is not an option for existing databases, nor does it solve the problem in (future) cases where the database may attempt to store NULL values in other, not-nullable, fields. IMO the db layer has to deal with this: if a field cannot be NULL, do not store NULL, but an acceptable default value. Ofcourse what is an acceptable default depends on the field type - for a NODE field -1 may not be useful as a value (but then again, it is only a real problem is the db uses referential integrity for NODE fields, which most now dont).
Hide
Michiel Meeuwissen added a comment - 1970-01-01 00:59
NODEs are always references. Filling in -1 would be simply avoiding the problem, becasue you simply mean 'NULL' then, and using -1 seems a bit silly to me.

I'd say that NODE typed fields must always be nullable.
Show
Michiel Meeuwissen added a comment - 1970-01-01 00:59 NODEs are always references. Filling in -1 would be simply avoiding the problem, becasue you simply mean 'NULL' then, and using -1 seems a bit silly to me. I'd say that NODE typed fields must always be nullable.
Hide
Henk Hangyi added a comment - 2007-02-25 12:43
IMO the default value approach for fields is the best solution. Is this already possible in the present builder syntax or do we have to extend it to make this possible? Lets try to create an intelligent solution for the 1.9 release.
Show
Henk Hangyi added a comment - 2007-02-25 12:43 IMO the default value approach for fields is the best solution. Is this already possible in the present builder syntax or do we have to extend it to make this possible? Lets try to create an intelligent solution for the 1.9 release.
Hide
Michiel Meeuwissen added a comment - 2007-02-25 17:34
I think a default value of -1 is not feasible, because a NODE field is essentially a foreign key. There is no node with number -1.

I remain of the opinion that a NODE field _must_ be nullable. You must be honost about such cases, if you don't know a value you msut use null.
Show
Michiel Meeuwissen added a comment - 2007-02-25 17:34 I think a default value of -1 is not feasible, because a NODE field is essentially a foreign key. There is no node with number -1. I remain of the opinion that a NODE field _must_ be nullable. You must be honost about such cases, if you don't know a value you msut use null.
Hide
Michiel Meeuwissen added a comment - 2010-12-30 12:00
I think it's fixed.
Show
Michiel Meeuwissen added a comment - 2010-12-30 12:00 I think it's fixed.

People

Dates

  • Created:
    2003-06-10 08:34
    Updated:
    2010-12-30 12:00
    Resolved:
    2010-12-30 12:00