On Mar 31, 11:41 am, cult hero <[email protected]> wrote:
> This doesn't necessarily have to be a bug, but it's odd as the
> following migration code works fine in PostgreSQL but not sqlite.
>
> This code dies: primary_key :id, String, size: 32
>
> I get the following error from sqlite: Error: Sequel::DatabaseError:
> SQLite3::SQLException: AUTOINCREMENT is only allowed on an INTEGER
> PRIMARY KEY/usr/local/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5/lib/
> sqlite3/errors.rb:62:in `check'
>
> Whereas, if I change it up a bit:
>
> String :id, size: 32
> primary_key [:id]
>
> It works fine. Either I'm using shorthand I shouldn't that happens to
> work in PostgreSQL, or there's an issue with the sqlite adapter.

The primary_key method with a Symbol is for creating an
autoincrementing key.  For string primary keys, I recommend:

  String :id, :size=>43, :primary_key=>true

As you've found out, using primary_key with an array works as well,
though it's only necessary for composite primary keys.

The reason it works on postgres is because postgres uses the serial
type, which you are overriding by providing a String type.  However,
that behavior should not be relied upon.

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.

Reply via email to