Permalink
Browse files

Correctly swallow errors when using :ignore_index_errors in Database#…

…create_table when using unsupported indexes (Fixes #295)
  • Loading branch information...
jeremyevans committed Apr 27, 2010
1 parent 6e1fafc commit 64b33200664f9aed299e7db46228f11fa7bd1bed
Showing with 14 additions and 3 deletions.
  1. +2 −0 CHANGELOG
  2. +3 −3 lib/sequel/database/schema_methods.rb
  3. +9 −0 spec/core/schema_spec.rb
View
@@ -1,5 +1,7 @@
=== HEAD
+* Correctly swallow errors when using :ignore_index_errors in Database#create_table when using unsupported indexes (jeremyevans) (#295)
+
* Fix returning autogenerated keys when using the 5.1.12 MySQL JDBC driver (viking)
* Consider number/numeric/decimal columns with a 0 scale to be integer columns (e.g. numeric(10, 0)) (jeremyevans, QaDes)
@@ -191,10 +191,10 @@ def create_table_from_generator(name, generator, options)
# Execute the create index statements using the generator.
def create_table_indexes_from_generator(name, generator, options)
e = options[:ignore_index_errors]
- index_sql_list(name, generator.indexes).each do |sql|
+ generator.indexes.each do |index|
begin
- execute_ddl(sql)
- rescue DatabaseError
+ index_sql_list(name, [index]).each{|sql| execute_ddl(sql)}
+ rescue Error
raise unless e
end
end
View
@@ -299,6 +299,15 @@
@db.sqls.should == ["CREATE TABLE cats (name text, UNIQUE (name))"]
end
+ specify "should not raise on index error for unsupported index definitions if ignore_index_errors is used" do
+ proc {
+ @db.create_table(:cats, :ignore_index_errors=>true) do
+ text :name
+ full_text_index :name
+ end
+ }.should_not raise_error
+ end
+
specify "should raise on full-text index definitions" do
proc {
@db.create_table(:cats) do

0 comments on commit 64b3320

Please sign in to comment.