Included Modules

Class Index [+]

Quicksearch

Sequel::JDBC::HSQLDB::DatabaseMethods

Instance methods for HSQLDB Database objects accessed via JDBC.

Constants

PRIMARY_KEY_INDEX_RE

Public Instance Methods

database_type() click to toggle source

HSQLDB uses the :hsqldb database type.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 14
14:         def database_type
15:           :hsqldb
16:         end
db_version() click to toggle source

The version of the database, as an integer (e.g 2.2.5 -> 20205)

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 25
25:         def db_version
26:           @db_version ||= begin
27:             v = get{DATABASE_VERSION(){}}
28:             if v =~ /(\d+)\.(\d+)\.(\d+)/
29:               $1.to_i * 10000 + $2.to_i * 100 + $3.to_i
30:             end
31:           end
32:         end
serial_primary_key_options() click to toggle source

HSQLDB uses an IDENTITY sequence as the default value for primary key columns.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 20
20:         def serial_primary_key_options
21:           {:primary_key => true, :type => :integer, :identity=>true, :start_with=>1}
22:         end

Private Instance Methods

alter_table_sql(table, op) click to toggle source

HSQLDB specific SQL for renaming columns, and changing column types and/or nullity.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 37
37:         def alter_table_sql(table, op)
38:           case op[:op]
39:           when :rename_column
40:             "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} RENAME TO #{quote_identifier(op[:new_name])}"
41:           when :set_column_type
42:             "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} SET DATA TYPE #{type_literal(op)}"
43:           when :set_column_null
44:             "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} SET #{op[:null] ? 'NULL' : 'NOT NULL'}"
45:           else
46:             super
47:           end
48:         end
create_table_as_sql(name, sql, options) click to toggle source

HSQLDB requires parens around the SELECT, and the WITH DATA syntax.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 51
51:         def create_table_as_sql(name, sql, options)
52:           "#{create_table_prefix_sql(name, options)} AS (#{sql}) WITH DATA"
53:         end
last_insert_id(conn, opts={}) click to toggle source

Use IDENTITY() to get the last inserted id.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 56
56:         def last_insert_id(conn, opts={})
57:           statement(conn) do |stmt|
58:             sql = 'CALL IDENTITY()'
59:             rs = log_yield(sql){stmt.executeQuery(sql)}
60:             rs.next
61:             rs.getInt(1)
62:           end
63:         end
primary_key_index_re() click to toggle source

Primary key indexes appear to start with sys_idx_sys_pk_ on HSQLDB

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 66
66:         def primary_key_index_re
67:           PRIMARY_KEY_INDEX_RE
68:         end
type_literal(column) click to toggle source

If an :identity option is present in the column, add the necessary IDENTITY SQL. It’s possible to use an IDENTITY type, but that defaults the sequence to start at 0 instead of 1, and we don’t want that.

    # File lib/sequel/adapters/jdbc/hsqldb.rb, line 73
73:         def type_literal(column)
74:           if column[:identity]
75:             sql = "#{super} GENERATED BY DEFAULT AS IDENTITY"
76:             if sw = column[:start_with]
77:               sql << " (START WITH #{sw.to_i}"
78:               sql << " INCREMENT BY #{column[:increment_by].to_i}" if column[:increment_by]
79:               sql << ")"
80:             end
81:             sql
82:           else
83:             super
84:           end
85:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.