Class: ActiveRecord::ConnectionAdapters::SQLite3::Column

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/sqlite3/column.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Column

#collation, #comment, #default, #default_function, #name, #null, #sql_type_metadata

Instance Method Summary collapse

Methods inherited from Column

#auto_populated?, #bigint?, #has_default?, #human_name, #virtual?

Methods included from Deduplicable

#deduplicate

Constructor Details

#initialize(auto_increment: nil, rowid: false) ⇒ Column

Returns a new instance of Column.



9
10
11
12
13
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 9

def initialize(*, auto_increment: nil, rowid: false, **)
  super
  @auto_increment = auto_increment
  @rowid = rowid
end

Instance Attribute Details

#rowidObject (readonly)

Returns the value of attribute rowid.



7
8
9
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 7

def rowid
  @rowid
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



33
34
35
36
37
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 33

def ==(other)
  other.is_a?(Column) &&
    super &&
    auto_increment? == other.auto_increment?
end

#auto_increment?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 15

def auto_increment?
  @auto_increment
end

#auto_incremented_by_db?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 19

def auto_incremented_by_db?
  auto_increment? || rowid
end

#encode_with(coder) ⇒ Object



28
29
30
31
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 28

def encode_with(coder)
  coder["auto_increment"] = @auto_increment
  super
end

#hashObject



40
41
42
43
44
45
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 40

def hash
  Column.hash ^
    super.hash ^
    auto_increment?.hash ^
    rowid.hash
end

#init_with(coder) ⇒ Object



23
24
25
26
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 23

def init_with(coder)
  @auto_increment = coder["auto_increment"]
  super
end