Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn

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

Overview

PostgreSQL-specific extensions to column definitions in a table.

Instance Attribute Summary

Attributes inherited from Column

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

Instance Method Summary collapse

Methods inherited from Column

#==, #bigint?, #encode_with, #has_default?, #hash, #human_name, #init_with

Constructor Details

#initialize(max_identifier_length: 63) ⇒ PostgreSQLColumn

Returns a new instance of PostgreSQLColumn.



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

def initialize(*, max_identifier_length: 63, **)
  super
  @max_identifier_length = max_identifier_length
end

Instance Method Details

#serial?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 15

def serial?
  return unless default_function

  if %r{\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z} =~ default_function
    sequence_name_from_parts(table_name, name, suffix) == sequence_name
  end
end