Module: ArJdbc::Oracle::Column
- Included in:
- ActiveRecord::ConnectionAdapters::OracleColumn
- Defined in:
- lib/arjdbc/oracle/adapter.rb
Class Method Summary collapse
- .guess_date_or_time(value) ⇒ Object
- .string_to_dummy_time(string) ⇒ Object
- .string_to_time(string) ⇒ Object
Instance Method Summary collapse
- #extract_limit(sql_type) ⇒ Object
- #primary=(val) ⇒ Object
- #type_cast(value) ⇒ Object
- #type_cast_code(var_name) ⇒ Object
Class Method Details
.guess_date_or_time(value) ⇒ Object
96 97 98 99 100 |
# File 'lib/arjdbc/oracle/adapter.rb', line 96 def self.guess_date_or_time(value) return value if value.is_a? Date ( value && value.hour == 0 && value.min == 0 && value.sec == 0 ) ? Date.new(value.year, value.month, value.day) : value end |
.string_to_dummy_time(string) ⇒ Object
92 93 94 |
# File 'lib/arjdbc/oracle/adapter.rb', line 92 def self.string_to_dummy_time(string) ::ActiveRecord::ConnectionAdapters::JdbcColumn.string_to_dummy_time(string) end |
.string_to_time(string) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/arjdbc/oracle/adapter.rb', line 84 def self.string_to_time(string) return string unless string.is_a?(String) return nil if string.empty? return Time.now if string.index('CURRENT') == 0 # TODO seems very wrong ::ActiveRecord::ConnectionAdapters::JdbcColumn.string_to_time(string) end |
Instance Method Details
#extract_limit(sql_type) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/arjdbc/oracle/adapter.rb', line 58 def extract_limit(sql_type) case sql_type when /^(clob|date)/i; nil else super end end |
#primary=(val) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/arjdbc/oracle/adapter.rb', line 51 def primary=(val) super if val && @sql_type =~ /^NUMBER$/i @type = :integer end end |
#type_cast(value) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/arjdbc/oracle/adapter.rb', line 65 def type_cast(value) return nil if value.nil? case type when :datetime then ArJdbc::Oracle::Column.string_to_time(value) when :timestamp then ArJdbc::Oracle::Column.string_to_time(value) else super end end |
#type_cast_code(var_name) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/arjdbc/oracle/adapter.rb', line 75 def type_cast_code(var_name) case type when :datetime then "ArJdbc::Oracle::Column.string_to_time(#{var_name})" when :timestamp then "ArJdbc::Oracle::Column.string_to_time(#{var_name})" else super end end |