Hi Jeremey,
The patches work great. Thanks for getting it working so quickly.
Sunny
On Nov 5, 7:17 pm, Jeremy Evans <[EMAIL PROTECTED]> wrote:
> On Nov 5, 3:12 pm, Sunny Hirai <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi Jeremy,
>
> > Thanks Jeremy. It passes the 12 unit tests related to Sequel in my
> > library.
>
> > Also, some more information on the Database#create_table bug with an
> > index.
>
> > I can work around it by explicitly calling #add_index on the Database
> > object and using String#lit instead of Symbol#identifier.
>
> > After taking a look at the code and doing some testing, it looks like
> > a bunch of methods that rely on #alter_table share the same bug. For
> > example, #add_column also fails with Symbol#identifier but works with
> > String#lit.
>
> > # altering a table
> > db.add_column :my__table.identifier, :description, :text
>
> > the above will fail but below will work:
>
> > # altering a table
> > db.add_column :my__table.to_s.lit, :description, :text
>
> > Here's the stack trace for #add_column with a Symbol#identifier:
>
> > wrong number of arguments (0 for 1)
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
> > shared/mysql.rb, line: 195, method: to_s »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
> > shared/mysql.rb, line: 195, method: quoted_identifier »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/dataset/
> > sql.rb, line: 568, method: quote_identifier »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
> > sql.rb, line: 197, method: quote_identifier »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
> > shared/mysql.rb, line: 17, method: alter_table_sql »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
> > sql.rb, line: 54, method: alter_table_sql_list »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
> > sql.rb, line: 54, method: map »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
> > sql.rb, line: 54, method: alter_table_sql_list »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/database/
> > schema.rb, line: 45, method: alter_table »
> > c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/database/
> > schema.rb, line: 11, method: add_column »
>
> > I appreciate the time you are spending on keeping the library clean.
>
> As the stacktrace shows, it's a bug in the MySQL adapter. Try this
> patch:
>
> diff --git a/lib/sequel_core/adapters/shared/mysql.rb b/lib/
> sequel_core/adapters/shared/mysql.rb
> index 7d44536..065bb2a 100644
> --- a/lib/sequel_core/adapters/shared/mysql.rb
> +++ b/lib/sequel_core/adapters/shared/mysql.rb
> @@ -14,13 +14,11 @@ module Sequel
> # Use MySQL specific syntax for rename column, set column type,
> and
> # drop index cases.
> def alter_table_sql(table, op)
> - quoted_table = quote_identifier(table)
> - quoted_name = quote_identifier(op[:name]) if op[:name]
> case op[:op]
> when :rename_column
> - "ALTER TABLE #{quoted_table} CHANGE COLUMN #{quoted_name}
> #{quote_identifier(op[:new_name])} #{type_literal(op)}"
> + "ALTER TABLE #{quote_schema_table(table)} CHANGE COLUMN
> #{quote_identifier(op[:name])} #{quote_identifier(op[:new_name])}
> #{type_literal(op)}"
> when :set_column_type
> - "ALTER TABLE #{quoted_table} CHANGE COLUMN #{quoted_name}
> #{quoted_name} #{type_literal(op)}"
> + "ALTER TABLE #{quote_schema_table(table)} CHANGE COLUMN
> #{quote_identifier(op[:name])} #{quote_identifier(op[:name])}
> #{type_literal(op)}"
> when :drop_index
> "#{drop_index_sql(table, op)} ON #{quoted_table}"
> else
> @@ -50,7 +48,7 @@ module Sequel
> using = " USING #{index[:type]}" unless index[:type] == nil
> "UNIQUE " if index[:unique]
> end
> - "CREATE #{index_type}INDEX #{index_name} ON
> #{quote_identifier(table_name)} #{literal(index[:columns])}#{using}"
> + "CREATE #{index_type}INDEX #{index_name} ON
> #{quote_schema_table(table_name)} #{literal(index[:columns])}#{using}"
> end
>
> # Get version of MySQL server, used for determined
> capabilities.
>
> Please let me know how that works.
>
> Thanks,
> 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
-~----------~----~----~----~------~----~------~--~---