taobot wrote:
Hi Ola,

I may have an example of where it would be desirable to have a default of
255 rather that allowing the server's maximum varchar length to be used. I'm
using the current out-of-the-box activerecord-jdbc along with a Sybase ASE
server over JTDS.
Running rake db:migrate in my rails app stalls at the point where it tries
to run in the unique index on the schema_migrations table. The message

rake aborted!
ActiveRecord::ActiveRecordError: 600 is the maximum allowable size of an
index.  Composite index specified is 2048 bytes.
: CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations
(version)
is given. It turns out that this is because the schema_migrations table has
(by default) been created with a version column typed as varchar(2048). The
table creation works, but since the subsequent creation of a unique index on
schema_migrations references the column, the schema migration process barfs
because the maximum width of an index is 600.

Would you advocate a change to modify_types in this case?

Cheers
Stuart
Well, no. Not really. Since this is once again a situation where one specific driver/database is fubar. That shouldn't affect the defaults for other databases, right?

Cheers

Ola Bini-3 wrote:
Clint Hill wrote:
If I choose to limit the size to 255 as a default - is the proper place to do that in the modify_types method call like so?

  def modify_types(tp)
     tp[:primary_key] = "NUMBER(38) NOT NULL PRIMARY KEY"
     tp[:integer] = { :name => "NUMBER", :limit => 38 }
     tp[:datetime] = { :name => "DATE" }
     tp[:timestamp] = { :name => "DATE" }
     tp[:time] = { :name => "DATE" }
     tp[:date] = { :name => "DATE" }
     tp[:string][:limit] = 255                <==========
     tp
   end

No, definitely not. The default value _should_ be 4000. If I remember correctly, there are some tests in Rails that hinge on that for Oracle. Or at least there used to be. So modify your own code to take that into account - not the adapter code. Why do you want to limit it to 255, btw? There is no real reason unless you have a business need to not store strings longer than 255 - and in that case that should be expressed in your application anyway.

Cheers




--
Ola Bini (http://olabini.com) Ioke creator (http://ioke.org)
JRuby Core Developer (http://jruby.org)
Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

"Yields falsehood when quined" yields falsehood when quined.



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to