Module: ArJdbc::MSSQL::Utils
- Included in:
- ArJdbc::MSSQL
- Defined in:
- lib/arjdbc/mssql/utils.rb
Class Method Summary collapse
-
.remove_identifier_delimiters(keyword) ⇒ Object
See “Delimited Identifiers”: http://msdn.microsoft.com/en-us/library/ms176027.aspx.
-
.unqualify_db_name(table_name) ⇒ Object
-
.unqualify_table_name(table_name) ⇒ Object
-
.unqualify_table_schema(table_name) ⇒ Object
-
.unquote_column_name(column_name) ⇒ Object
-
.unquote_string(string) ⇒ Object
-
.unquote_table_name(table_name) ⇒ Object
Class Method Details
.remove_identifier_delimiters(keyword) ⇒ Object
See “Delimited Identifiers”: http://msdn.microsoft.com/en-us/library/ms176027.aspx
63 64 65 |
# File 'lib/arjdbc/mssql/utils.rb', line 63 def remove_identifier_delimiters(keyword) keyword.to_s.tr("\]\[\"", '') end |
.unqualify_db_name(table_name) ⇒ Object
55 56 57 58 |
# File 'lib/arjdbc/mssql/utils.rb', line 55 def unqualify_db_name(table_name) table_names = table_name.to_s.split('.') table_names.length == 3 ? remove_identifier_delimiters(table_names.first) : nil end |
.unqualify_table_name(table_name) ⇒ Object
45 46 47 48 |
# File 'lib/arjdbc/mssql/utils.rb', line 45 def unqualify_table_name(table_name) return if table_name.blank? remove_identifier_delimiters(table_name.to_s.split('.').last) end |
.unqualify_table_schema(table_name) ⇒ Object
50 51 52 53 |
# File 'lib/arjdbc/mssql/utils.rb', line 50 def unqualify_table_schema(table_name) schema_name = table_name.to_s.split('.')[-2] schema_name.nil? ? nil : remove_identifier_delimiters(schema_name) end |
.unquote_column_name(column_name) ⇒ Object
37 38 39 |
# File 'lib/arjdbc/mssql/utils.rb', line 37 def unquote_column_name(column_name) remove_identifier_delimiters(column_name) end |
.unquote_string(string) ⇒ Object
41 42 43 |
# File 'lib/arjdbc/mssql/utils.rb', line 41 def unquote_string(string) string.to_s.gsub("''", "'") end |
.unquote_table_name(table_name) ⇒ Object
33 34 35 |
# File 'lib/arjdbc/mssql/utils.rb', line 33 def unquote_table_name(table_name) remove_identifier_delimiters(table_name) end |