Module: Sequel::JDBC::Derby::DatabaseMethods

Extended by:
Database::ResetIdentifierMangling
Includes:
Transactions
Defined in:
lib/sequel/adapters/jdbc/derby.rb

Overview

Instance methods for Derby Database objects accessed via JDBC.

Constant Summary collapse

PRIMARY_KEY_INDEX_RE =
/\Asql\d+\z/i.freeze

Constants included from Transactions

Transactions::TRANSACTION_BEGIN, Transactions::TRANSACTION_COMMIT, Transactions::TRANSACTION_RELEASE_SP, Transactions::TRANSACTION_ROLLBACK, Transactions::TRANSACTION_ROLLBACK_SP, Transactions::TRANSACTION_SAVEPOINT

Instance Method Summary collapse

Methods included from Database::ResetIdentifierMangling

extended

Methods included from Transactions

#supports_savepoints?, #supports_transaction_isolation_levels?

Instance Method Details

#cast_type_literal(type) ⇒ Object

Derby doesn’t support casting integer to varchar, only integer to char, and char(254) appears to have the widest support (with char(255) failing). This does add a bunch of extra spaces at the end, but those will be trimmed elsewhere.



18
19
20
# File 'lib/sequel/adapters/jdbc/derby.rb', line 18

def cast_type_literal(type)
  (type == String) ? 'CHAR(254)' : super
end

#database_typeObject

Derby uses the :derby database type.



23
24
25
# File 'lib/sequel/adapters/jdbc/derby.rb', line 23

def database_type
  :derby
end

#serial_primary_key_optionsObject

Derby uses an IDENTITY sequence for autoincrementing columns.



28
29
30
# File 'lib/sequel/adapters/jdbc/derby.rb', line 28

def serial_primary_key_options
  {:primary_key => true, :type => :integer, :identity=>true, :start_with=>1}
end

#supports_transactional_ddl?Boolean

Derby supports transaction DDL statements.

Returns:

  • (Boolean)


42
43
44
# File 'lib/sequel/adapters/jdbc/derby.rb', line 42

def supports_transactional_ddl?
  true
end

#svn_versionObject

The SVN version of the database.



33
34
35
36
37
38
39
# File 'lib/sequel/adapters/jdbc/derby.rb', line 33

def svn_version
  @svn_version ||= begin
    v = synchronize{|c| c..get_database_product_version}
    v =~ /\((\d+)\)\z/
    $1.to_i
  end
end