Sha256: d11630bd7f6d37d9132746b9463bd617ab6c87b86781666ef88fb1e52ef7998a

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

# frozen-string-literal: true

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

module Sequel
  module Swift
    # Database and Dataset instance methods for MySQL specific
    # support via Swift.
    module MySQL
      # Database instance methods for MySQL databases accessed via Swift.
      module DatabaseMethods
        extend Sequel::Database::ResetIdentifierMangling
        include Sequel::MySQL::DatabaseMethods
        
        private
        
        # The database name for the given database.
        def database_name
          opts[:database]
        end

        # Consider tinyint(1) columns as boolean.
        def schema_column_type(db_type)
          db_type =~ /\Atinyint\(1\)/ ? :boolean : super
        end
      
        # Apply the connectiong setting SQLs for every new connection.
        def setup_connection(conn)
          mysql_connection_setting_sqls.each{|sql| log_connection_yield(sql, conn){conn.execute(sql)}}
          super
        end
      end
      
      # Dataset class for MySQL datasets accessed via Swift.
      class Dataset < Swift::Dataset
        include Sequel::MySQL::DatasetMethods
        APOS = Dataset::APOS
        
        private
        
        # Use Swift's escape method for quoting.
        def literal_string_append(sql, s)
          sql << APOS << db.synchronize(@opts[:server]){|c| c.escape(s)} << APOS
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
sequel-4.41.0 lib/sequel/adapters/swift/mysql.rb
sequel-4.40.0 lib/sequel/adapters/swift/mysql.rb
sequel-4.39.0 lib/sequel/adapters/swift/mysql.rb
tdiary-5.0.2 vendor/bundle/gems/sequel-4.37.0/lib/sequel/adapters/swift/mysql.rb
sequel-4.38.0 lib/sequel/adapters/swift/mysql.rb
sequel-4.37.0 lib/sequel/adapters/swift/mysql.rb
sequel-4.36.0 lib/sequel/adapters/swift/mysql.rb
tdiary-5.0.1 vendor/bundle/gems/sequel-4.35.0/lib/sequel/adapters/swift/mysql.rb
sequel-4.35.0 lib/sequel/adapters/swift/mysql.rb