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
101 102 103 104 105 |
# File 'lib/arjdbc/oracle/adapter.rb', line 101 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
97 98 99 |
# File 'lib/arjdbc/oracle/adapter.rb', line 97 def self.string_to_dummy_time(string) ::ActiveRecord::ConnectionAdapters::JdbcColumn.string_to_dummy_time(string) end |
.string_to_time(string) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/arjdbc/oracle/adapter.rb', line 89 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
63 64 65 66 67 68 |
# File 'lib/arjdbc/oracle/adapter.rb', line 63 def extract_limit(sql_type) case sql_type when /^(clob|date)/i; nil else super end end |
#primary=(val) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/arjdbc/oracle/adapter.rb', line 56 def primary=(val) super if val && @sql_type =~ /^NUMBER$/i @type = :integer end end |
#type_cast(value) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/arjdbc/oracle/adapter.rb', line 70 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
80 81 82 83 84 85 86 87 |
# File 'lib/arjdbc/oracle/adapter.rb', line 80 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 |