Class: ActiveRecord::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ignore_table_columns(*args) ⇒ Object

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

ignore_table_columns :attribute1, :attribute2


20
21
22
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 20

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.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 4

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, config)
  else
    ConnectionAdapters::OracleEnhancedAdapter.new(
      ConnectionAdapters::OracleEnhancedConnection.create(config), logger, config)
  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


41
42
43
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 41

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


27
28
29
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 27

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


34
35
36
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 34

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


50
51
52
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 50

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_string_columns :active_flag


58
59
60
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 58

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

.table_commentObject

Get table comment from schema definition.



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

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

.virtual_columnsObject



82
83
84
85
86
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 82

def self.virtual_columns
  columns.select do |column|
    column.respond_to?(:virtual?) && column.virtual?
  end
end

Instance Method Details

#arel_attributes_values_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) ⇒ Object



96
97
98
99
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 96

def arel_attributes_values_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
  virtual_column_names = self.class.virtual_columns.map(&:name)
  arel_attributes_values_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
end

#attributes_with_quotes_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) ⇒ Object



89
90
91
92
# File 'lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb', line 89

def attributes_with_quotes_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
  virtual_column_names = self.class.virtual_columns.map(&:name)
  attributes_with_quotes_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
end