update composite primary key table problem

Let's say we have table user_role('user_id', 'role_id') with data:

[table]

[tr]

[td]user_id[/td][td]role_id[/td]

[/tr]

[tr]

[td]2[/td][td]1[/td]

[/tr]

[/table]

I want to update this record to be:

[table]

[tr]

[td]user_id[/td][td]role_id[/td]

[/tr]

[tr]

[td]2[/td][td]2[/td]

[/tr]

[/table]

In controller file, I have sth like:

I expect it to generate sql like:

However, I got this instead (from the log):

As a result, my record never get updated. I am just wondering how can I get composite primary key table updated, am I missing sth here?

EDIT:

Currently, I can only find a workaround like this:

Just wondering if Yii AR can 'remember' the old composite PK key value so that we can use update instead of doing delete and insert to save one DB operation.

Anyone interested?

You may use UserHasRole()::model()->updateByPk(…)