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?, #human_name

Methods included from Deduplicable

#deduplicate

Constructor Details

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

Returns a new instance of Column.



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

def initialize(*, auto_increment: nil, rowid: false, generated_type: nil, **)
  super
  @auto_increment = auto_increment
  @rowid = rowid
  @generated_type = generated_type
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?



46
47
48
49
50
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 46

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

#auto_increment?Boolean

Returns:

  • (Boolean)


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

def auto_increment?
  @auto_increment
end

#auto_incremented_by_db?Boolean

Returns:

  • (Boolean)


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

def auto_incremented_by_db?
  auto_increment? || rowid
end

#encode_with(coder) ⇒ Object



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

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

#has_default?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 32

def has_default?
  super && !virtual?
end

#hashObject



53
54
55
56
57
58
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 53

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

#init_with(coder) ⇒ Object



36
37
38
39
# File 'lib/active_record/connection_adapters/sqlite3/column.rb', line 36

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

#virtual?Boolean

Returns:

  • (Boolean)


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

def virtual?
  !@generated_type.nil?
end

#virtual_stored?Boolean

Returns:

  • (Boolean)


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

def virtual_stored?
  virtual? && @generated_type == :stored
end