Default values 0 and null in AR

I’m not really sure if this is a bug or not, though I think it is:

I have a table in an SQLite DB with (among others) an integer field that is allowed to be null and its default value is also set to null. When I instantiate a model based on that table, the corresponding value is initialized as 0 instead of null. This gives me problems when I use CExistValidator, as blank values are allowed but a value of 0 is checked (and doesn’t exist in the primary table), and thus results in a validation error.

This does seem like a bug, since 0 and null are different values. I can’t fix this with CDefaultValueValidator since the value isn’t ‘’ or null. Before I start hacking with isNewRecord in the model constructor, is there a better way to fix this, either in the model or in the db?

I’d really like some input on this one.

i use mysql, no this problem

(yii 1.1 rc)

mysql schema:


CREATE TABLE yii_user (

  id int(11) NOT NULL AUTO_INCREMENT,

  username varchar(64) NOT NULL,

  `password` varchar(64) NOT NULL,

  created int(11) DEFAULT NULL,

  updated int(11) DEFAULT NULL,

  PRIMARY KEY (id)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8;



controller:


$user = new User;

dump( $user->attributes );

screen print:


array

(

    [id] => null

    [username] => null

    [password] => null

    [created] => null

    [updated] => null

)

Thanks, I’ll go file an issue then :)