class ActiveRecord::ConnectionAdapters::SQLServer::Column

Public Class Methods

new(*, is_identity: nil, is_primary: nil, table_name: nil, ordinal_position: nil, **) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 9
def initialize(*, is_identity: nil, is_primary: nil, table_name: nil, ordinal_position: nil, **)
  super
  @is_identity = is_identity
  @is_primary = is_primary
  @table_name = table_name
  @ordinal_position = ordinal_position
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 50
def ==(other)
  other.is_a?(Column) &&
    super &&
    is_identity? == other.is_identity? &&
    is_primary? == other.is_primary? &&
    table_name == other.table_name &&
    ordinal_position == other.ordinal_position
end
Also aliased as: eql?
auto_incremented_by_db?()
Alias for: is_identity?
case_sensitive?() click to toggle source
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 30
def case_sensitive?
  collation && collation.match(/_CS/)
end
encode_with(coder) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 42
def encode_with(coder)
  coder["is_identity"] = @is_identity
  coder["is_primary"] = @is_primary
  coder["table_name"] = @table_name
  coder["ordinal_position"] = @ordinal_position
  super
end
eql?(other)
Alias for: ==
hash() click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 60
def hash
  Column.hash ^
    super.hash ^
    is_identity?.hash ^
    is_primary?.hash ^
    table_name.hash ^
    ordinal_position.hash
end
init_with(coder) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 34
def init_with(coder)
  @is_identity = coder["is_identity"]
  @is_primary = coder["is_primary"]
  @table_name = coder["table_name"]
  @ordinal_position = coder["ordinal_position"]
  super
end
is_identity?() click to toggle source
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 17
def is_identity?
  is_identity
end
Also aliased as: auto_incremented_by_db?
is_primary?() click to toggle source
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 22
def is_primary?
  is_primary
end
is_utf8?() click to toggle source
# File lib/active_record/connection_adapters/sqlserver_column.rb, line 26
def is_utf8?
  sql_type =~ /nvarchar|ntext|nchar/i
end

Private Instance Methods

deduplicated() click to toggle source

In the Rails version of this method there is an assumption that the ‘default` value will always be a `String` class, which must be true for the MySQL/PostgreSQL/SQLite adapters. However, in the SQL Server adapter the `default` value can also be Boolean/Date/Time/etc. Changed the implementation of this method to handle non-String `default` objects.

# File lib/active_record/connection_adapters/sqlserver_column.rb, line 75
def deduplicated
  @name = -name
  @sql_type_metadata = sql_type_metadata.deduplicate if sql_type_metadata
  @default = (default.is_a?(String) ? -default : default.dup.freeze) if default
  @default_function = -default_function if default_function
  @collation = -collation if collation
  @comment = -comment if comment
  freeze
end