Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/oracle_enhanced_adapter.rb

Class Method Summary collapse

Class Method Details

.add_order_with_lobs!(sql, order, scope = :auto) ⇒ Object Also known as: add_order!

patch ORDER BY to work with LOBs



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 112

def add_order_with_lobs!(sql, order, scope = :auto)
  if connection.is_a?(ConnectionAdapters::OracleEnhancedAdapter)
    order = connection.lob_order_by_expression(self, order) if order
    
    orig_scope = scope
    scope = scope(:find) if :auto == scope
    if scope
      new_scope_order = connection.lob_order_by_expression(self, scope[:order])
      if new_scope_order != scope[:order]
        scope = scope.merge(:order => new_scope_order)
      else
        scope = orig_scope
      end
    end
  end
  add_order_without_lobs!(sql, order, scope = :auto)
end

.ignore_table_columns(*args) ⇒ Object

Specify table columns which should be ignored by ActiveRecord, e.g.:

ignore_table_columns :attribute1, :attribute2


57
58
59
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 57

def self.ignore_table_columns(*args)
  connection.ignore_table_columns(table_name,*args)
end

.oracle_enhanced_connection(config) ⇒ Object

Establishes a connection to the database that’s used by all Active Record objects.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 41

def self.oracle_enhanced_connection(config) #:nodoc:
  if config[:emulate_oracle_adapter] == true
    # allows the enhanced adapter to look like the OracleAdapter. Useful to pick up
    # conditionals in the rails activerecord test suite
    require 'active_record/connection_adapters/emulation/oracle_adapter'
    ConnectionAdapters::OracleAdapter.new(
      ConnectionAdapters::OracleEnhancedConnection.create(config), logger)
  else
    ConnectionAdapters::OracleEnhancedAdapter.new(
      ConnectionAdapters::OracleEnhancedConnection.create(config), logger)
  end
end

.set_boolean_columns(*args) ⇒ Object

Specify which table columns should be typecasted to boolean values true or false, e.g.:

set_boolean_columns :is_valid, :is_completed


78
79
80
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 78

def self.set_boolean_columns(*args)
  connection.set_type_for_columns(table_name,:boolean,*args)
end

.set_date_columns(*args) ⇒ Object

Specify which table columns should be typecasted to Date (without time), e.g.:

set_date_columns :created_on, :updated_on


64
65
66
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 64

def self.set_date_columns(*args)
  connection.set_type_for_columns(table_name,:date,*args)
end

.set_datetime_columns(*args) ⇒ Object

Specify which table columns should be typecasted to Time (or DateTime), e.g.:

set_datetime_columns :created_date, :updated_date


71
72
73
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 71

def self.set_datetime_columns(*args)
  connection.set_type_for_columns(table_name,:datetime,*args)
end

.set_integer_columns(*args) ⇒ Object

Specify which table columns should be typecasted to integer values. Might be useful to force NUMBER(1) column to be integer and not boolean, or force NUMBER column without scale to be retrieved as integer and not decimal. Example:

set_integer_columns :version_number, :object_identifier


87
88
89
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 87

def self.set_integer_columns(*args)
  connection.set_type_for_columns(table_name,:integer,*args)
end

.set_string_columns(*args) ⇒ Object

Specify which table columns should be typecasted to string values. Might be useful to specify that columns should be string even if its name matches boolean column criteria.

set_integer_columns :active_flag


95
96
97
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 95

def self.set_string_columns(*args)
  connection.set_type_for_columns(table_name,:string,*args)
end

.table_commentObject

Get table comment from schema definition.



137
138
139
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 137

def self.table_comment
  connection.table_comment(self.table_name)
end