Module: ArJdbc::SQLite3::Column
- Included in:
- ActiveRecord::ConnectionAdapters::SQLite3Column
- Defined in:
- lib/arjdbc/sqlite3/adapter.rb
Overview
Instance Method Summary collapse
- #default_value(value) ⇒ Object
- #init_column(name, default, *args) ⇒ Object
- #type_cast(value) ⇒ Object
Instance Method Details
#default_value(value) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 35 def default_value(value) # JDBC returns column default strings with actual single quotes : return $1 if value =~ /^'(.*)'$/ value end |
#init_column(name, default, *args) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 26 def init_column(name, default, *args) if default =~ /NULL/ @default = nil else super end end |
#type_cast(value) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 43 def type_cast(value) return nil if value.nil? case type when :string then value when :primary_key value.respond_to?(:to_i) ? value.to_i : ( value ? 1 : 0 ) when :float then value.to_f when :decimal then self.class.value_to_decimal(value) when :boolean then self.class.value_to_boolean(value) else super end end |