Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Some small fixes for MySQL and for upcasing identifiers on JDBC

This changes Dataset#upcase_identifiers? to lazily load the setting.
Previously, it was handled in Database#initialize, but on JDBC (and
other adapters that have subadapters), the method that provides the
default hasn't been included in the class when Database#initialize
tried to use it, so this would end up with identifiers being upcased
when using MySQL, PostgreSQL, or SQLite on JDBC.

This fixes Database#alter_table for MySQL, for the drop_index case,
and fixes the MySQL schema parser to handle the fact that the table
name provided to schema_parse_table is now a string instead of a
  • Loading branch information...
commit d407190e95e48f5de778d7b6e8ef99410b259796 1 parent ace69a0
@jeremyevans authored
4 lib/sequel_core/adapters/shared/mysql.rb
@@ -20,7 +20,7 @@ def alter_table_sql(table, op)
when :set_column_type
"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}"
+ "#{drop_index_sql(table, op)} ON #{quote_schema_table(table)}"
super(table, op)
@@ -80,7 +80,7 @@ def upcase_identifiers_default
# Use the MySQL specific DESCRIBE syntax to get a table description.
def schema_parse_table(table_name, opts)
- self["DESCRIBE ?", table_name].map do |row|
+ self["DESCRIBE ?",].map do |row|
row[:allow_null] = row.delete(:Null) == 'YES'
row[:default] = row.delete(:Default)
3  lib/sequel_core/database.rb
@@ -58,7 +58,6 @@ def initialize(opts = {}, &block)
@opts = opts
@quote_identifiers = opts.include?(:quote_identifiers) ? opts[:quote_identifiers] : @@quote_identifiers
- @upcase_identifiers = opts.include?(:upcase_identifiers) ? opts[:upcase_identifiers] : (@@upcase_identifiers.nil? ? upcase_identifiers_default : @@upcase_identifiers)
@single_threaded = opts.include?(:single_threaded) ? opts[:single_threaded] : @@single_threaded
@schemas = nil
@prepared_statements = {}
@@ -475,7 +474,7 @@ def typecast_value(column_type, value)
# Returns true if the database upcases identifiers.
def upcase_identifiers?
- @upcase_identifiers
+ @upcase_identifiers ||= @opts.include?(:upcase_identifiers) ? @opts[:upcase_identifiers] : (@@upcase_identifiers.nil? ? upcase_identifiers_default : @@upcase_identifiers)
# Returns the URI identifying the database.

0 comments on commit d407190

Please sign in to comment.
Something went wrong with that request. Please try again.