Skip to content

Commit

Permalink
Make Database#indexes not include primary key indexes on jdbc/db2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jan 23, 2012
1 parent d12e0f0 commit 754b89b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Wrap column default values in extra parens on SQLite, fixes some cases (jeremyevans)

* Make Database#indexes not include primary key indexes on Derby and HSQLDB (jeremyevans)
* Make Database#indexes not include primary key indexes on Derby, HSQLDB, and DB2 using the jdbc adapter (jeremyevans)

* Support Database#indexes in shared MSSQL adapter (jeremyevans)

Expand Down
7 changes: 7 additions & 0 deletions lib/sequel/adapters/jdbc/db2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Database
module DB2
# Database instance methods for DB2 databases accessed via JDBC.
module DatabaseMethods
PRIMARY_KEY_INDEX_RE = /\Asql\d+\z/i.freeze

include Sequel::DB2::DatabaseMethods
include Sequel::JDBC::Transactions
IDENTITY_VAL_LOCAL = "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1".freeze
Expand All @@ -34,6 +36,11 @@ def last_insert_id(conn, opts={})
rs.getInt(1)
end
end

# Primary key indexes appear to be named sqlNNNN on DB2
def primary_key_index_re
PRIMARY_KEY_INDEX_RE
end
end

# Dataset class for DB2 datasets accessed via JDBC.
Expand Down

0 comments on commit 754b89b

Please sign in to comment.