Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
Class Method Summary collapse
-
.ignore_table_columns(*args) ⇒ Object
Specify table columns which should be ignored by ActiveRecord, e.g.:.
- .lob_columns ⇒ Object
-
.set_boolean_columns(*args) ⇒ Object
Specify which table columns should be typecasted to boolean values
true
orfalse
, e.g.:. -
.set_date_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Date (without time), e.g.:.
-
.set_datetime_columns(*args) ⇒ Object
Specify which table columns should be typecasted to Time (or DateTime), e.g.:.
-
.set_integer_columns(*args) ⇒ Object
Specify which table columns should be typecasted to integer values.
-
.set_string_columns(*args) ⇒ Object
Specify which table columns should be typecasted to string values.
-
.table_comment ⇒ Object
Get table comment from schema definition.
- .virtual_columns ⇒ Object
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
51 52 53 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 51 def self.ignore_table_columns(*args) connection.ignore_table_columns(table_name,*args) end |
.lob_columns ⇒ Object
98 99 100 101 102 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 98 def self.lob_columns columns.select do |column| column.respond_to?(:lob?) && column.lob? 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
72 73 74 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 72 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
58 59 60 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 58 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
65 66 67 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 65 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
81 82 83 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 81 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
89 90 91 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 89 def self.set_string_columns(*args) connection.set_type_for_columns(table_name,:string,*args) end |
.table_comment ⇒ Object
Get table comment from schema definition.
94 95 96 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 94 def self.table_comment connection.table_comment(self.table_name) end |
.virtual_columns ⇒ Object
104 105 106 107 108 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 104 def self.virtual_columns columns.select do |column| column.respond_to?(:virtual?) && column.virtual? end end |
Instance Method Details
#arel_attributes_with_values(attribute_names) ⇒ Object
110 111 112 113 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 110 def arel_attributes_with_values(attribute_names) virtual_column_names = self.class.virtual_columns.map(&:name) super(attribute_names - virtual_column_names) end |