On Oct 12, 2:40 pm, Aman Gupta <[email protected]> wrote: > On Mon, Oct 12, 2009 at 2:37 PM, cult hero <[email protected]> wrote: > > > Hmmm... okay, now what if my primary key is autoincrementing? > > new_model = MyModel.create(model.values.merge(:id => nil))
First, Sequel's defaults will raise an error for that, since it doesn't let you to mass assign to the primary key field by default. Even if it does work, the results of that are database dependent. That will attempt to insert a NULL value into the primary key field, instead of leaving the primary key field unspecified (which should make the database use the default value). SQLite allows this using the default value for the column, PostgreSQL raises an error. I'm guessing MySQL behavior is similar to SQLite's. I think PostgreSQL's behavior is the most correct. Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
