On the bright side, you've got a dedicated #identifier tester. :) On
the less bright side, found a few more bugs related to it.
Calling Database#schema with or without a table name results in an
error.
If called without a table name (i.e. return all table schemas), and
you have some any tables with double underscores in them, I get this
error:
Mysql::Error Table 'my.table' doesn't exist - Sequel::DatabaseError
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 179, method: query »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 179, method: _execute »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 138, method: execute »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/
connection_pool.rb, line: 105, method: hold »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/
database.rb, line: 335, method: synchronize »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 138, method: execute »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/
dataset.rb, line: 455, method: execute »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 305, method: execute »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
mysql.rb, line: 258, method: fetch_rows »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/
dataset.rb, line: 445, method: _each »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/
dataset.rb, line: 205, method: each »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/dataset/
convenience.rb, line: 94, method: map »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/dataset/
convenience.rb, line: 94, method: map »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/adapters/
shared/mysql.rb, line: 78, method: schema_parse_table »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
sql.rb, line: 236, method: schema »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
sql.rb, line: 244, method: schema »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
sql.rb, line: 244, method: each »
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
sql.rb, line: 244, method: schema »
If called with a table identifier, I get this error:
undefined method `to_sym' for # - NoMethodError
c:/ruby/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_core/schema/
sql.rb, line: 216, method: schema »
Sunny
On Nov 6, 3:21 pm, Sunny Hirai <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---