Class: ActiveRecord::ConnectionAdapters::SQLite3Column
- Inherits:
-
JdbcColumn
- Object
- Column
- JdbcColumn
- ActiveRecord::ConnectionAdapters::SQLite3Column
- Defined in:
- lib/arjdbc/sqlite3/adapter.rb
Instance Attribute Summary
Attributes inherited from JdbcColumn
Class Method Summary collapse
Instance Method Summary collapse
- #default_value(value) ⇒ Object
- #init_column(name, default, *args) ⇒ Object
-
#initialize(name, *args) ⇒ SQLite3Column
constructor
A new instance of SQLite3Column.
- #type_cast(value) ⇒ Object
Methods inherited from JdbcColumn
Constructor Details
#initialize(name, *args) ⇒ SQLite3Column
Returns a new instance of SQLite3Column.
575 576 577 578 579 580 581 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 575 def initialize(name, *args) if Hash === name super else super(nil, name, *args) end end |
Class Method Details
.binary_to_string(value) ⇒ Object
587 588 589 590 591 592 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 587 def self.binary_to_string(value) if value.respond_to?(:encoding) && value.encoding != Encoding::ASCII_8BIT value = value.force_encoding(Encoding::ASCII_8BIT) end value end |
.string_to_binary(value) ⇒ Object
583 584 585 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 583 def self.string_to_binary(value) value end |
Instance Method Details
#default_value(value) ⇒ Object
604 605 606 607 608 609 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 604 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
595 596 597 598 599 600 601 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 595 def init_column(name, default, *args) if default =~ /NULL/ @default = nil else super end end |
#type_cast(value) ⇒ Object
612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 612 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 |