Sha256: e7a88acef214cbf908d327802cb49ea9d631a8e224a707f41af9f0de83fce84f

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 KB

Contents

Sequel.require 'adapters/shared/sqlite'

module Sequel
  module JDBC
    # Database and Dataset support for SQLite databases accessed via JDBC.
    module SQLite
      # Instance methods for SQLite Database objects accessed via JDBC.
      module DatabaseMethods
        include Sequel::SQLite::DatabaseMethods
        
        # Return Sequel::JDBC::SQLite::Dataset object with the given opts.
        def dataset(opts=nil)
          Sequel::JDBC::SQLite::Dataset.new(self, opts)
        end
        
        private
        
        # Use last_insert_rowid() to get the last inserted id.
        def last_insert_id(conn, opts={})
          stmt = conn.createStatement
          begin
            rs = stmt.executeQuery('SELECT last_insert_rowid()')
            rs.next
            rs.getInt(1)
          ensure
            stmt.close
          end
        end
        
        # Default to a single connection for a memory database.
        def connection_pool_default_options
          o = super
          uri == 'jdbc:sqlite::memory:' ? o.merge(:max_connections=>1) : o
        end
        
        # Execute the connection pragmas on the connection.
        def setup_connection(conn)
          conn = super(conn)
          begin
            stmt = conn.createStatement
            connection_pragmas.each{|s| log_yield(s){stmt.execute(s)}}
          ensure
            stmt.close if stmt
          end
          conn
        end
      end
      
      # Dataset class for SQLite datasets accessed via JDBC.
      class Dataset < JDBC::Dataset
        include Sequel::SQLite::DatasetMethods
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
sequel-3.20.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.19.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.18.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.17.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.16.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.15.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.14.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.13.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.12.1 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.12.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.11.0 lib/sequel/adapters/jdbc/sqlite.rb
viking-sequel-3.10.0 lib/sequel/adapters/jdbc/sqlite.rb