Class: ActiveRecord::ConnectionAdapters::MSSQLColumn
- Inherits:
-
JdbcColumn
- Object
- Column
- JdbcColumn
- ActiveRecord::ConnectionAdapters::MSSQLColumn
- Includes:
- ArJdbc::MSSQL::Column
- Defined in:
- lib/arjdbc/mssql/column.rb,
lib/arjdbc/mssql/old_adapter.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.
Attributes inherited from JdbcColumn
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #extract_default(value) ⇒ Object
- #hash ⇒ Object
- #identity? ⇒ Boolean
-
#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
Methods included from ArJdbc::MSSQL::Column
#default_value, #extract_limit, #is_utf8?, #primary?, #simplified_type, #type_cast
Methods included from ArJdbc::MSSQL::LockMethods
Methods inherited from JdbcColumn
column_types, #default_value, #init_column
Constructor Details
#initialize(name, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil) ⇒ MSSQLColumn
Returns a new instance of 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?
33 34 35 36 37 |
# File 'lib/arjdbc/mssql/column.rb', line 33 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
40 41 42 43 44 |
# File 'lib/arjdbc/mssql/column.rb', line 40 def hash MSSQLColumn.hash ^ super.hash ^ table_name.hash end |
#identity? ⇒ Boolean
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 |