Sha256: 26b0cbd9138ab239515a5b8ce606e89bf3c6e495a1ae0e0d6a471bf9168833a2

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

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
        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 == 'tinyint(1)' ? :boolean : super
        end
      
        # By default, MySQL 'where id is null' selects the last inserted id.
        # Turn that off unless explicitly enabled.
        def setup_connection(conn)
          super
          sql = "SET SQL_AUTO_IS_NULL=0"
          log_yield(sql){conn.execute(sql)} unless opts[:auto_is_null]
          conn
        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{|c| c.escape(s)} << APOS
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sequel-3.35.0 lib/sequel/adapters/swift/mysql.rb
sequel-3.34.1 lib/sequel/adapters/swift/mysql.rb
sequel-3.34.0 lib/sequel/adapters/swift/mysql.rb