Sha256: 700ebd50422d387b3613bcf26300af5db3fb8eea156059f360529d3ce52a5f7b
Contents?: true
Size: 1009 Bytes
Versions: 4
Compression:
Stored size: 1009 Bytes
Contents
# frozen_string_literal: true module ActiveRecord module ConnectionAdapters # MSSQL specific extensions to column definitions in a table. class MSSQLColumn < Column attr_reader :table_name def initialize(name, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) @table_name = table_name default = extract_default(raw_default) super(name, default, sql_type_metadata, null, default_function, collation: collation, comment: comment) end def extract_default(value) # return nil if default does not match the patterns to avoid # any unexpected errors. return unless value =~ /^\(N?'(.*)'\)$/m || value =~ /^\(\(?(.*?)\)?\)$/ unquote_string(Regexp.last_match[1]) end def unquote_string(string) string.to_s.gsub("''", "'") end def identity? sql_type.downcase.include? 'identity' end end end end
Version data entries
4 entries across 4 versions & 1 rubygems