module Sequel::JDBC::SQLite::DatabaseMethods

Constants

DATABASE_ERROR_REGEXPS

Public Instance Methods

foreign_key_list(table, opts=OPTS) click to toggle source

Swallow pointless exceptions when the foreign key list pragma doesn't return any rows.

   # File lib/sequel/adapters/jdbc/sqlite.rb
23 def foreign_key_list(table, opts=OPTS)
24   super
25 rescue Sequel::DatabaseError => e
26   raise unless foreign_key_error?(e)
27   []
28 end
indexes(table, opts=OPTS) click to toggle source

Swallow pointless exceptions when the index list pragma doesn't return any rows.

Calls superclass method Sequel::SQLite::DatabaseMethods#indexes
   # File lib/sequel/adapters/jdbc/sqlite.rb
32 def indexes(table, opts=OPTS)
33   super
34 rescue Sequel::DatabaseError => e
35   raise unless foreign_key_error?(e)
36   {}
37 end

Private Instance Methods

connection_pool_default_options() click to toggle source

Default to a single connection for a memory database.

Calls superclass method
   # File lib/sequel/adapters/jdbc/sqlite.rb
56 def connection_pool_default_options
57   o = super
58   uri == 'jdbc:sqlite::memory:' ? o.merge(:max_connections=>1) : o
59 end
database_error_regexps() click to toggle source
   # File lib/sequel/adapters/jdbc/sqlite.rb
42 def database_error_regexps
43   DATABASE_ERROR_REGEXPS
44 end
foreign_key_error?(exception) click to toggle source

Whether the given exception is due to a foreign key error.

   # File lib/sequel/adapters/jdbc/sqlite.rb
71 def foreign_key_error?(exception)
72   exception.message =~ /query does not return ResultSet/
73 end
last_insert_id(conn, opts=OPTS) click to toggle source

Use last_insert_rowid() to get the last inserted id.

   # File lib/sequel/adapters/jdbc/sqlite.rb
47 def last_insert_id(conn, opts=OPTS)
48   statement(conn) do |stmt|
49     rs = stmt.executeQuery('SELECT last_insert_rowid()')
50     rs.next
51     rs.getLong(1)
52   end
53 end
setup_connection(conn) click to toggle source

Execute the connection pragmas on the connection.

Calls superclass method
   # File lib/sequel/adapters/jdbc/sqlite.rb
62 def setup_connection(conn)
63   conn = super(conn)
64   statement(conn) do |stmt|
65     connection_pragmas.each{|s| log_connection_yield(s, conn){stmt.execute(s)}}
66   end
67   conn
68 end
setup_type_convertor_map() click to toggle source

Use getLong instead of getInt for converting integers on SQLite, since SQLite does not enforce a limit of 2**32. Work around regressions in jdbc-sqlite 3.8.7 for date and blob types.

Calls superclass method
   # File lib/sequel/adapters/jdbc/sqlite.rb
77 def setup_type_convertor_map
78   super
79   @type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT]
80   @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] = @basic_type_convertor_map[Java::JavaSQL::Types::BIGINT]
81   x = @type_convertor_map[Java::JavaSQL::Types::DATE] = Object.new
82   def x.call(r, i)
83     if v = r.getString(i)
84       Sequel.string_to_date(v)
85     end
86   end
87   x = @type_convertor_map[Java::JavaSQL::Types::BLOB] = Object.new
88   def x.call(r, i)
89     if v = r.getBytes(i)
90       Sequel::SQL::Blob.new(String.from_java_bytes(v))
91     elsif !r.wasNull
92       Sequel::SQL::Blob.new('')
93     end
94   end
95 end
sqlite_error_code(exception) click to toggle source

The result code for the exception, if the jdbc driver supports result codes for exceptions.

    # File lib/sequel/adapters/jdbc/sqlite.rb
 98 def sqlite_error_code(exception)
 99   exception.resultCode.code if exception.respond_to?(:resultCode)
100 end