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


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
>>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ActiveRecord-JDBC-Oracle-string-default-question-tp20956312p22425756.html
Sent from the JRuby - Dev mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email


Reply via email to