Permalink
Browse files

Use clob for String :text=>true types on Oracle, DB2, HSQLDB, and Derby

Previously, attempting to use String :text=>true in a migration
failed on these databases, since it uses the text type by
default, and these databases don't support that type.
  • Loading branch information...
1 parent 49ec50b commit d2167dcc2361ae2b8f6c2aa91c9d6eb32103dde8 @jeremyevans committed Sep 24, 2012
View
@@ -1,5 +1,7 @@
=== HEAD
+* Use clob for String :text=>true types on Oracle, DB2, HSQLDB, and Derby (jeremyevans) (#555)
+
* Allowing marshalling of Sequel::Postgres::HStore (jeremyevans) (#556)
* Quote channel identifier names when using LISTEN/NOTIFY on PostgreSQL (jeremyevans)
@@ -148,6 +148,11 @@ def type_literal(column)
super
end
end
+
+ # Derby uses clob for text types.
+ def uses_clob_for_text?
+ true
+ end
end
# Dataset class for Derby datasets accessed via JDBC.
@@ -83,6 +83,11 @@ def type_literal(column)
super
end
end
+
+ # HSQLDB uses clob for text types.
+ def uses_clob_for_text?
+ true
+ end
end
# Dataset class for HSQLDB datasets accessed via JDBC.
@@ -189,6 +189,11 @@ def type_literal_generic_trueclass(column)
:smallint
end
alias type_literal_generic_falseclass type_literal_generic_trueclass
+
+ # DB2 uses clob for text types.
+ def uses_clob_for_text?
+ true
+ end
end
module DatasetMethods
@@ -178,6 +178,11 @@ def type_literal_generic_trueclass(column)
def temporary_table_sql
TEMPORARY
end
+
+ # Oracle uses clob for text types.
+ def uses_clob_for_text?
+ true
+ end
end
module DatasetMethods
@@ -783,7 +783,7 @@ def type_literal_generic_numeric(column)
# :text option is used, Sequel uses the :text type.
def type_literal_generic_string(column)
if column[:text]
- :text
+ uses_clob_for_text? ? :clob : :text
elsif column[:fixed]
"char(#{column[:size]||255})"
else
@@ -811,5 +811,10 @@ def type_literal_specific(column)
elements = column[:size] || column[:elements]
"#{type}#{literal(Array(elements)) if elements}#{UNSIGNED if column[:unsigned]}"
end
+
+ # Whether clob should be used for String :text=>true columns.
+ def uses_clob_for_text?
+ false
+ end
end
end
@@ -60,6 +60,12 @@ def create_items_table_with_column(name, type, opts={})
ds.all.should == [{:name=>'Test User'}]
end
+ specify "should support generic text type" do
+ ds = create_items_table_with_column(:name, String, :text=>true)
+ ds.insert(:name => 'Test User'*100)
+ ds.all.should == [{:name=>'Test User'*100}]
+ end
+
cspecify "should support generic date type", [:do, :sqlite], [:jdbc, :sqlite], :mssql, :oracle do
ds = create_items_table_with_column(:dat, Date)
d = Date.today

0 comments on commit d2167dc

Please sign in to comment.