Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Correctly swallow errors when using :ignore_index_errors in Database#…

…create_table when using unsupported indexes (Fixes #295)
  • Loading branch information...
commit 64b33200664f9aed299e7db46228f11fa7bd1bed 1 parent 6e1fafc
Jeremy Evans authored April 26, 2010
2  CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 === HEAD
2 2
 
  3
+* Correctly swallow errors when using :ignore_index_errors in Database#create_table when using unsupported indexes (jeremyevans) (#295)
  4
+
3 5
 * Fix returning autogenerated keys when using the 5.1.12 MySQL JDBC driver (viking)
4 6
 
5 7
 * Consider number/numeric/decimal columns with a 0 scale to be integer columns (e.g. numeric(10, 0)) (jeremyevans, QaDes)
6  lib/sequel/database/schema_methods.rb
@@ -191,10 +191,10 @@ def create_table_from_generator(name, generator, options)
191 191
     # Execute the create index statements using the generator.
192 192
     def create_table_indexes_from_generator(name, generator, options)
193 193
       e = options[:ignore_index_errors]
194  
-      index_sql_list(name, generator.indexes).each do |sql|
  194
+      generator.indexes.each do |index|
195 195
         begin
196  
-          execute_ddl(sql)
197  
-        rescue DatabaseError
  196
+          index_sql_list(name, [index]).each{|sql| execute_ddl(sql)}
  197
+        rescue Error
198 198
           raise unless e
199 199
         end
200 200
       end
9  spec/core/schema_spec.rb
@@ -299,6 +299,15 @@
299 299
     @db.sqls.should == ["CREATE TABLE cats (name text, UNIQUE (name))"]
300 300
   end
301 301
 
  302
+  specify "should not raise on index error for unsupported index definitions if ignore_index_errors is used" do
  303
+    proc {
  304
+      @db.create_table(:cats, :ignore_index_errors=>true) do
  305
+        text :name
  306
+        full_text_index :name
  307
+      end
  308
+    }.should_not raise_error
  309
+  end
  310
+
302 311
   specify "should raise on full-text index definitions" do
303 312
     proc {
304 313
       @db.create_table(:cats) do

0 notes on commit 64b3320

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