Class: ActiveRecord::ConnectionAdapters::YugabyteDB::Column

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(serial: nil, identity: nil, generated: nil) ⇒ Column

Returns a new instance of Column.



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

def initialize(*, serial: nil, identity: nil, generated: nil, **)
  super
  @serial = serial
  @identity = identity
  @generated = generated
end

Instance Method Details

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



64
65
66
67
68
69
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 64

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

#arrayObject Also known as: array?



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

def array
  .sql_type.end_with?("[]")
end

#auto_incremented_by_db?Boolean

Returns:

  • (Boolean)


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

def auto_incremented_by_db?
  serial? || identity?
end

#encode_with(coder) ⇒ Object



57
58
59
60
61
62
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 57

def encode_with(coder)
  coder["serial"] = @serial
  coder["identity"] = @identity
  coder["generated"] = @generated
  super
end

#enum?Boolean

Returns:

  • (Boolean)


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

def enum?
  type == :enum
end

#has_default?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 33

def has_default?
  super && !virtual?
end

#hashObject



72
73
74
75
76
77
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 72

def hash
  Column.hash ^
    super.hash ^
    identity?.hash ^
    serial?.hash
end

#identity?Boolean

Returns:

  • (Boolean)


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

def identity?
  @identity
end

#init_with(coder) ⇒ Object



50
51
52
53
54
55
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 50

def init_with(coder)
  @serial = coder["serial"]
  @identity = coder["identity"]
  @generated = coder["generated"]
  super
end

#serial?Boolean

Returns:

  • (Boolean)


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

def serial?
  @serial
end

#sql_typeObject



46
47
48
# File 'lib/active_record/connection_adapters/yugabytedb/column.rb', line 46

def sql_type
  super.delete_suffix("[]")
end

#virtual?Boolean

Returns:

  • (Boolean)


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

def virtual?
  # We assume every generated column is virtual, no matter the concrete type
  @generated.present?
end