Module: SchemaPlus::ActiveRecord::ConnectionAdapters::SQLiteColumn

Defined in:
lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

AR 4.2 uses default_function rather than default_expr


13
14
15
# File 'lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb', line 13

def self.included(base)
  base.alias_method_chain :default_function, :sqlite3 if base.instance_methods.include? :default_function
end

Instance Method Details

#default_function_with_sqlite3Object


17
18
19
20
# File 'lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb', line 17

def default_function_with_sqlite3
  @default_function ||= "(#{default})" if default =~ /DATETIME/
  default_function_without_sqlite3
end

#initialize(name, default, sql_type = nil, null = true) ⇒ Object


5
6
7
8
9
10
# File 'lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb', line 5

def initialize(name, default, sql_type = nil, null = true)
  if default =~ /DATETIME/
    @default_expr = "(#{default})"
  end
  super(name, default, sql_type, null)
end