Strange behaviour when using custom primary key

When is used custom primary key in model, ex>

protected $primaryKey = 'my_field';

Default query generated for searching is probaby ok, appending model prefix like model_my_field

SELECT .... WHERE model_my_field = ...

But… When u tried to update fields with $model->save();
this query was generated without model prefix field, and searching for clean $primaryKey.

UPDATE .... WHERE my_field = ...

@daft

Hey @snipi

Changing the primary key will also change the default keys of all relations. The model_my_field looks like it is a relationship key that is also different now.

I hope this helps.