On Mar 1, 11:18 pm, Clive Crous <[email protected]> wrote:
> Not sure why I didn't think about this before or how "hackish" this may
> seem, but borrowing function usage for mysql works fine, which means that
> you can do this in the current Sequel source base:
>
> require 'rubygems'
> require 'sequel'
> require 'logger'
>
> DB = Sequel.open( 'mysql://r...@localhost/tmp', :loggers => [ Logger.new(
> STDOUT ) ] )
>
> DB.create_table :test do
>   primary_key :id
>   column :firstname, :text
>   column :lastname, :text
>   index [ :lastname[256], :firstname[128] ]
>   index :lastname[32]
> end
>
> =>
>
> I, [2009-03-02T09:16:08.056302 #4446]  INFO -- : CREATE TABLE `test` (`id`
> integer PRIMARY KEY AUTO_INCREMENT, `firstname` text, `lastname` text)
> I, [2009-03-02T09:16:08.060792 #4446]  INFO -- : CREATE INDEX
> `test_lastname_256__firstname_128__index` ON `test` (lastname(256),
> firstname(128))
> I, [2009-03-02T09:16:08.063126 #4446]  INFO -- : CREATE INDEX
> `test_lastname_32__index` ON `test` (lastname(32))

Do NOT do this.  While it may work now (unless you are on Ruby 1.9),
there is no guarantee that it will work in the future.  You are
passing an SQL::Function to the index method, so it works now purely
by accident.  Until Sequel supports this directly (if ever), use
String#lit.

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