Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make regexps adapt to newer error messages in SQLite 3.8 #766

Merged
merged 1 commit into from

2 participants

@itswindtw

Hi,

It seems that SQLite 3.8.2+ changed their error message formats for unique, foreign key and not null constraints.
That makes spec/integration/database_test.rb fail:

1) Sequel::Database constraint violations should raise Sequel::UniqueConstraintViolation when a unique constraint is violated
   Failure/Error: Unable to find matching line from backtrace
     expected Sequel::UniqueConstraintViolation, got #<Sequel::DatabaseError: SQLite3::ConstraintException: UNIQUE constraint failed: test.a> with backtrace:
       # ./lib/sequel/adapters/sqlite.rb:181:in `block (2 levels) in _execute'
       # ./lib/sequel/database/logging.rb:33:in `log_yield'
...

So I did a small modification to fix it. Hope it can help!

@jeremyevans
Owner

This looks good, I'll merge and test shortly. Thanks for the patch!

@jeremyevans jeremyevans merged commit 672de3d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/sequel/adapters/shared/sqlite.rb
View
6 lib/sequel/adapters/shared/sqlite.rb
@@ -332,10 +332,10 @@ def create_view_prefix_sql(name, options)
end
DATABASE_ERROR_REGEXPS = {
- /(is|are) not unique\z/ => UniqueConstraintViolation,
- /foreign key constraint failed\z/ => ForeignKeyConstraintViolation,
+ /(is|are) not unique\z|UNIQUE constraint failed: .+\z/ => UniqueConstraintViolation,
+ /foreign key constraint failed\z|FOREIGN KEY constraint failed\z/ => ForeignKeyConstraintViolation,
/\A(SQLITE ERROR 19 \(CONSTRAINT\) : )?constraint failed\z/ => ConstraintViolation,
- /may not be NULL\z/ => NotNullConstraintViolation,
+ /may not be NULL\z|NOT NULL constraint failed: .+\z/ => NotNullConstraintViolation,
}.freeze
def database_error_regexps
DATABASE_ERROR_REGEXPS
Something went wrong with that request. Please try again.