Reputation: 2619
Is there a way to tell mysql to ignore any tentative to assign any value to an auto-increment column?. We are using slick and it seems to try to assign the value of 0 to any auto-increment column at the time a new row is created. These auto-increment columns are not primary keys.
Upvotes: 0
Views: 56
Reputation: 15941
With a before insert trigger, you should be able to do something like SET NEW.id = NULLIF(NEW.id, 0);
. Of course, this means nothing can ever insert 0 into the field without dropping the trigger first. (Though update queries still can still set it to 0).
Upvotes: 2