On Mar 23, 7:09 am, None <[email protected]> wrote: > Using a mysql db, v. mysql Ver 14.12 Distrib 5.0.68, for redhat-linux- > gnu (i686) using readline 5.1, and sequel 2.11.0: > > class Foo < Sequel::Migration > def up > create_table(:foo) do > primary_key :id > String :sid, :size => 255, :unique => true > end > end > def down > drop_table(:foo) > end > end > > yields: > > Mysql::Error You have an error in your SQL syntax; check the manual > that corresponds to your MySQL server version for the right syntax to > use near '(255) UNIQUE)' at line 1 > > Am I missing something? Bad DSL syntax? Or is this a bugito?
You shouldn't specify a :size modifier if you are providing a ruby class. Providing a ruby class means you want Sequel to pick the type. If your syntax worked, it would break on PostgreSQL (where String uses the text type, which doesn't allow a size modifier), and the whole point of using ruby classes is database independence. If you want a specific size, you need to specify a database type, not a ruby class: varchar :sid, :size => 255, :unique => true Sequel uses a varchar(255) field for String on MySQL anyway, so you can just use: String :sid, :unique => true You aren't the first person to bring this up as a possible issue, so I've added a note to the schema.rdoc file explaining this. 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 -~----------~----~----~----~------~----~------~--~---
