unset()ing AR attributes

The have something like the following (simplified):

<?php


$b = User::model()->findbyPk(1);


unset($b->password);


$b->save(false);

I expect that to retrieve the user with id 1, unset the password attribute, and then save it again, saving all the fields except the password.

So I expected it to output SQL like the following (assuming I just had a username and password field):

Executing SQL: INSERT INTO User (username) VALUES (:username)

Instead it tried to store NULL into the password field, which threw a mysql error.

It does however work as expected if it is an insert.

<?php


$b = new User;


$b->password = 'test';


unset($b->password);


$b->save(false);





//OR





$b = User::model()->findbyPk(1);


$b->isNewRecord = true; unset($b->id);


unset($b->password);


$b->save(false);


The above two examples will not store the password field because it was unset.  So it only seems to work with inserts but not updates.

The reason I want to unset the password on an update:

I have an update page where a user can change his/her password among other things.  If the user presses submit without changing his password (eg leaves the field blank), I want the following logic:

if (empty($user->password))

unset($user-&gt;password);

So it will not overwrite his password with a blank password.

So I guess this is a bug??

Thanks. Just fixed it.

It is a bug recently introduced.

Thanks!