Class: ActiveRecord::ConnectionAdapters::MSSQLColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::MSSQLColumn
- Defined in:
- lib/arjdbc/mssql/column.rb
Overview
MSSQL specific extensions to column definitions in a table.
Instance Attribute Summary collapse
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #extract_default(value) ⇒ Object
- #hash ⇒ Object
- #identity? ⇒ Boolean (also: #auto_incremented_by_db?)
-
#initialize(name, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) ⇒ MSSQLColumn
constructor
A new instance of MSSQLColumn.
- #unquote_string(string) ⇒ Object
Constructor Details
#initialize(name, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) ⇒ MSSQLColumn
9 10 11 12 13 14 15 |
# File 'lib/arjdbc/mssql/column.rb', line 9 def initialize(name, raw_default, = 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, , null, default_function, collation: collation, comment: comment) end |
Instance Attribute Details
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
7 8 9 |
# File 'lib/arjdbc/mssql/column.rb', line 7 def table_name @table_name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
34 35 36 37 38 |
# File 'lib/arjdbc/mssql/column.rb', line 34 def ==(other) other.is_a?(MSSQLColumn) && super && table_name == other.table_name end |
#extract_default(value) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/arjdbc/mssql/column.rb', line 17 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 |
#hash ⇒ Object
41 42 43 44 45 |
# File 'lib/arjdbc/mssql/column.rb', line 41 def hash MSSQLColumn.hash ^ super.hash ^ table_name.hash end |
#identity? ⇒ Boolean Also known as: auto_incremented_by_db?
29 30 31 |
# File 'lib/arjdbc/mssql/column.rb', line 29 def identity? sql_type.downcase.include? 'identity' end |
#unquote_string(string) ⇒ Object
25 26 27 |
# File 'lib/arjdbc/mssql/column.rb', line 25 def unquote_string(string) string.to_s.gsub("''", "'") end |