Sha256: 29c0878ca5e640eb2ea7260e87b6efbcbb5c03c417fe4e7571c84af5976ba6d4

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

require 'swift/db/postgres'
Sequel.require 'adapters/shared/postgres'

module Sequel
  Postgres::CONVERTED_EXCEPTIONS << ::Swift::Error
  
  module Swift
    # Adapter, Database, and Dataset support for accessing a PostgreSQL
    # database via Swift.
    module Postgres
      # Methods to add to Database instances that access PostgreSQL via Swift.
      module DatabaseMethods
        include Sequel::Postgres::DatabaseMethods
        
        # Add the primary_keys and primary_key_sequences instance variables,
        # so we can get the correct return values for inserted rows.
        def self.extended(db)
          db.send(:initialize_postgres_adapter)
        end
        
        private
        
        # Remove all other options except for ones specifically handled, as
        # otherwise swift passes them to dbic++ which passes them to PostgreSQL
        # which can raise an error.
        def server_opts(o)
          o = super
          so = {}
          [:db, :user, :password, :host, :port].each{|s| so[s] = o[s] if o.has_key?(s)}
          so
        end
      
        # Extend the adapter with the Swift PostgreSQL AdapterMethods.
        def setup_connection(conn)
          conn = super(conn)
          conn.native_bind_format = true
          connection_configuration_sqls.each{|sql| log_yield(sql){conn.execute(sql)}}
          conn
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sequel-3.47.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.46.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.45.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.44.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.43.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.42.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.41.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.40.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.39.0 lib/sequel/adapters/swift/postgres.rb
sequel-3.38.0 lib/sequel/adapters/swift/postgres.rb