Sha256: 6d3b666929ff522dd24b63510b0082a6a181b1c4a5a274d04fa950bd66f364dc

Contents?: true

Size: 1.83 KB

Versions: 11

Compression:

Stored size: 1.83 KB

Contents

# This source file contains extensions to the abstract adapter.
module ActiveRecord #:nodoc:
  module ConnectionAdapters #:nodoc:
    # Extensions to the AbstractAdapter. In some cases a default implementation
    # is provided, in others it is adapter-dependent and the method will
    # raise a NotImplementedError if the adapter does not implement that method
    class AbstractAdapter
      # Truncate the specified table
      def truncate(table_name)
        execute("TRUNCATE TABLE #{table_name}")
      end
      
      # Bulk loading interface. Load the data from the specified file into the
      # given table. Note that options will be adapter-dependent.
      def bulk_load(file, table_name, options={})
        raise ArgumentError, "#{file} does not exist" unless File.exist?(file)
        raise ArgumentError, "#{table_name} does not exist" unless tables.include?(table_name)
        do_bulk_load(file, table_name, options)
      end
      
      # SQL select into statement constructs a new table from the results
      # of a select. It is used to select data from a table and create a new
      # table with its result set at the same time.  Note that this method
      # name does not necessarily match the implementation.  E.g. MySQL's
      # version of this is 'CREATE TABLE ... AS SELECT ...'
      def support_select_into_table?
        false
      end
      
      # Add a chunk of SQL to the given query that will create a new table and
      # execute the select into that table.
      def add_select_into_table(new_table_name, sql_query)
        raise NotImplementedError, "add_select_into_table is an abstract method"
      end
      
      protected
      
      # for subclasses to implement
      def do_bulk_load(file, table_name, options={})
        raise NotImplementedError, "do_bulk_load is an abstract method"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
factorylabs-adapter_extensions-0.4.0.1 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
jayzes-adapter_extensions-0.4.0.1 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
mainej-adapter_extensions-0.4.0.1 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
adapter_extensions-0.9.5.rc1 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
activewarehouse-etl-0.9.5.rc1 test/vendor/adapter_extensions-0.5.0/lib/adapter_extensions/connection_adapters/abstract_adapter.rb
factorylabs-adapter_extensions-0.5.4 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
factorylabs-adapter_extensions-0.5.3 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
factorylabs-adapter_extensions-0.5.2 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
factorylabs-adapter_extensions-0.5.1 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
adapter_extensions-0.4.0 lib/adapter_extensions/connection_adapters/abstract_adapter.rb
adapter_extensions-0.5.0 lib/adapter_extensions/connection_adapters/abstract_adapter.rb