Module: JdbcSpec::SQLite3::Column
- Defined in:
- lib/jdbc_adapter/jdbc_sqlite3.rb
Instance Method Summary collapse
- #init_column(name, default, *args) ⇒ Object
- #type_cast(value) ⇒ Object
- #type_cast_code(var_name) ⇒ Object
Instance Method Details
#init_column(name, default, *args) ⇒ Object
52 53 54 |
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 52 def init_column(name, default, *args) @default = '' if default =~ /NULL/ end |
#type_cast(value) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 56 def type_cast(value) return nil if value.nil? case type when :string then value when :integer then JdbcSpec::SQLite3::Column.cast_to_integer(value) when :primary_key then defined?(value.to_i) ? value.to_i : (value ? 1 : 0) when :float then value.to_f when :datetime then JdbcSpec::SQLite3::Column.cast_to_date_or_time(value) when :date then JdbcSpec::SQLite3::Column.cast_to_date_or_time(value) when :time then JdbcSpec::SQLite3::Column.cast_to_time(value) when :decimal then self.class.value_to_decimal(value) when :boolean then self.class.value_to_boolean(value) else value end end |
#type_cast_code(var_name) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 72 def type_cast_code(var_name) case type when :integer then "JdbcSpec::SQLite3::Column.cast_to_integer(#{var_name})" when :datetime then "JdbcSpec::SQLite3::Column.cast_to_date_or_time(#{var_name})" when :date then "JdbcSpec::SQLite3::Column.cast_to_date_or_time(#{var_name})" when :time then "JdbcSpec::SQLite3::Column.cast_to_time(#{var_name})" else super end end |