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
41 def foreign_key_list(table, opts=OPTS)
42   super
43 rescue Sequel::DatabaseError => e
44   raise unless foreign_key_error?(e)
45   []
46 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
50 def indexes(table, opts=OPTS)
51   super
52 rescue Sequel::DatabaseError => e
53   raise unless foreign_key_error?(e)
54   {}
55 end

Private Instance Methods

_foreign_key_list_ds(_) click to toggle source

Add workaround for bug when running foreign_key_list pragma

   # File lib/sequel/adapters/jdbc/sqlite.rb
61 def _foreign_key_list_ds(_)
62   super.with_extend(ForeignKeyListPragmaConvertorFix)
63 end
_parse_pragma_ds(_, _) click to toggle source

Add workaround for bug when running table_info pragma

   # File lib/sequel/adapters/jdbc/sqlite.rb
66 def _parse_pragma_ds(_, _)
67   super.with_extend(TableInfoPragmaConvertorFix)
68 end
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
85 def connection_pool_default_options
86   o = super
87   uri == 'jdbc:sqlite::memory:' ? o.merge(:max_connections=>1) : o
88 end
database_error_regexps() click to toggle source
   # File lib/sequel/adapters/jdbc/sqlite.rb
71 def database_error_regexps
72   DATABASE_ERROR_REGEXPS
73 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
100 def foreign_key_error?(exception)
101   exception.message =~ /query does not return ResultSet/
102 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
76 def last_insert_id(conn, opts=OPTS)
77   statement(conn) do |stmt|
78     rs = stmt.executeQuery('SELECT last_insert_rowid()')
79     rs.next
80     rs.getLong(1)
81   end
82 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
91 def setup_connection(conn)
92   conn = super(conn)
93   statement(conn) do |stmt|
94     connection_pragmas.each{|s| log_connection_yield(s, conn){stmt.execute(s)}}
95   end
96   conn
97 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
106 def setup_type_convertor_map
107   super
108   @type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT]
109   @basic_type_convertor_map[Java::JavaSQL::Types::INTEGER] = @basic_type_convertor_map[Java::JavaSQL::Types::BIGINT]
110   x = @type_convertor_map[Java::JavaSQL::Types::DATE] = Object.new
111   def x.call(r, i)
112     if v = r.getString(i)
113       Sequel.string_to_date(v)
114     end
115   end
116   x = @type_convertor_map[Java::JavaSQL::Types::BLOB] = Object.new
117   def x.call(r, i)
118     if v = r.getBytes(i)
119       Sequel::SQL::Blob.new(String.from_java_bytes(v))
120     elsif !r.wasNull
121       Sequel::SQL::Blob.new('')
122     end
123   end
124 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
127 def sqlite_error_code(exception)
128   exception.resultCode.code if exception.respond_to?(:resultCode)
129 end