@@ -23,7 +23,8 @@ def get_table_name(sql, qualified = nil)
2323
2424 # protected
2525
26- def unquote_keyword ( keyword )
26+ # See "Delimited Identifiers": http://msdn.microsoft.com/en-us/library/ms176027.aspx
27+ def remove_identifier_delimiters ( keyword )
2728 if /\A (\[ |")(.*)/m . match ( keyword )
2829 delim , rest = $1, $2
2930 if delim == '[' && rest =~ /]\z / || delim == '"' && rest =~ /"\z /
@@ -34,28 +35,28 @@ def unquote_keyword(keyword)
3435 end
3536
3637 def unquote_table_name ( table_name )
37- unquote_keyword ( table_name )
38+ remove_identifier_delimiters ( table_name )
3839 end
3940
4041 def unquote_column_name ( column_name )
41- unquote_keyword ( column_name )
42+ remove_identifier_delimiters ( column_name )
4243 end
4344
4445 def unquote_string ( string )
4546 string . to_s . gsub ( "''" , "'" )
4647 end
4748
4849 def unqualify_table_name ( table_name )
49- unquote_keyword ( table_name . to_s . split ( '.' ) . last )
50+ remove_identifier_delimiters ( table_name . to_s . split ( '.' ) . last )
5051 end
5152
5253 def unqualify_table_schema ( table_name )
53- unquote_keyword ( table_name . to_s . split ( '.' ) [ -2 ] ) rescue nil
54+ remove_identifier_delimiters ( table_name . to_s . split ( '.' ) [ -2 ] ) rescue nil
5455 end
5556
5657 def unqualify_db_name ( table_name )
5758 table_names = table_name . to_s . split ( '.' )
58- table_names . length == 3 ? unquote_keyword ( table_names . first ) : nil
59+ table_names . length == 3 ? remove_identifier_delimiters ( table_names . first ) : nil
5960 end
6061
6162 end
0 commit comments