Skip to content

Commit

Permalink
Correctly swallow errors when using :ignore_index_errors in Database#…
Browse files Browse the repository at this point in the history
…create_table when using unsupported indexes (Fixes #295)
  • Loading branch information
jeremyevans committed Apr 27, 2010
1 parent 6e1fafc commit 64b3320
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lib/sequel/database/schema_methods.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/core/schema_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 64b3320

Please sign in to comment.