Sha256: 5743ad8820a040b0e2d85cc4426ecda5f8da2c7b9604928c28276e0421f31360

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 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
        LAST_INSERT_ROWID = 'SELECT last_insert_rowid()'.freeze
        
        private
        
        # Use last_insert_rowid() to get the last inserted id.
        def last_insert_id(conn, opts={})
          statement(conn) do |stmt|
            rs = stmt.executeQuery(LAST_INSERT_ROWID)
            rs.next
            rs.getInt(1)
          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)
          statement(conn) do |stmt|
            connection_pragmas.each{|s| log_yield(s){stmt.execute(s)}}
          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

4 entries across 4 versions & 1 rubygems

Version Path
sequel-3.33.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.32.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.31.0 lib/sequel/adapters/jdbc/sqlite.rb
sequel-3.30.0 lib/sequel/adapters/jdbc/sqlite.rb