Permalink
Browse files

do:mysql adapter treats tinyint(1) as boolean. The schema dumper will…

… now just check if the schema type is :boolean when deciding if to dump a tinyint as an integer or boolean
  • Loading branch information...
1 parent 751eb48 commit 2ac406b4067a333d526df7c66b543bd1c3ca118a @ricardochimal ricardochimal committed Mar 28, 2010
Showing with 5 additions and 1 deletion.
  1. +4 −0 lib/sequel/adapters/do/mysql.rb
  2. +1 −1 lib/sequel/extensions/schema_dumper.rb
@@ -22,6 +22,10 @@ def dataset(opts=nil)
def database_name
(m = /\/(.*)/.match(URI.parse(uri).path)) && m[1]
end
+
+ def schema_column_type(db_type)
+ db_type == 'tinyint(1)' ? :boolean : super
+ end
end
# Dataset class for MySQL datasets accessed via DataObjects.
@@ -115,7 +115,7 @@ def column_schema_to_ruby_type(schema)
when /\A(?:medium|small)?int(?:eger)?(?:\((?:\d+)\))?\z/o
{:type=>Integer}
when /\Atinyint(?:\((\d+)\))?\z/o
- {:type=>(self.class.adapter_scheme == :mysql && $1 == '1' && Sequel::MySQL.convert_tinyint_to_bool ? TrueClass : Integer)}
+ {:type =>schema[:type] == :boolean ? TrueClass : Integer}
when /\Abigint(?:\((?:\d+)\))?\z/o
{:type=>Bignum}
when /\A(?:real|float|double(?: precision)?)\z/o

0 comments on commit 2ac406b

Please sign in to comment.