Title: [1007] trunk/activerecord-jdbc: 20172: don't quote table names for MSSQL ( Thor Marius Henrichsen)
Revision
1007
Author
nicksieger
Date
2008-06-03 23:16:47 -0400 (Tue, 03 Jun 2008)

Log Message

20172: don't quote table names for MSSQL (Thor Marius Henrichsen)

Modified Paths


Diff

Modified: trunk/activerecord-jdbc/History.txt (1006 => 1007)


--- trunk/activerecord-jdbc/History.txt	2008-06-04 03:16:41 UTC (rev 1006)
+++ trunk/activerecord-jdbc/History.txt	2008-06-04 03:16:47 UTC (rev 1007)
@@ -11,6 +11,7 @@
 - JRUBY-1977, 17427: Fix information_schema select issue with MSSQL (Matt Burke)
 - 20479: Improve get_table_name for MSSQL (Aslak Hellesøy)
 - 20243: numerics improvements for MSSQL (Aslak Hellesøy)
+- 20172: don't quote table names for MSSQL (Thor Marius Henrichsen)
 
 == 0.8
 

Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb (1006 => 1007)


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb	2008-06-04 03:16:41 UTC (rev 1006)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb	2008-06-04 03:16:47 UTC (rev 1007)
@@ -118,32 +118,36 @@
         else
           "'#{quote_string(value)}'" # ' (for ruby-mode)
         end
-        when TrueClass             then '1'
-        when FalseClass            then '0'
-        when Time, DateTime        then "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
-        when Date                  then "'#{value.strftime("%Y%m%d")}'"
-        else                       super
+      when TrueClass             then '1'
+      when FalseClass            then '0'
+      when Time, DateTime        then "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
+      when Date                  then "'#{value.strftime("%Y%m%d")}'"
+      else                       super
       end
     end
 
-      def quote_string(string)
-        string.gsub(/\'/, "''")
-      end
+    def quote_string(string)
+      string.gsub(/\'/, "''")
+    end
 
-      def quote_column_name(name)
-        "[#{name}]"
-      end
+    def quote_table_name(name)
+      name
+    end
 
-      def change_order_direction(order)
-        order.split(",").collect {|fragment|
-          case fragment
-          when  /\bDESC\b/i     then fragment.gsub(/\bDESC\b/i, "ASC")
-          when  /\bASC\b/i      then fragment.gsub(/\bASC\b/i, "DESC")
-          else                  String.new(fragment).split(',').join(' DESC,') + ' DESC'
-          end
-        }.join(",")
-      end
+    def quote_column_name(name)
+      "[#{name}]"
+    end
 
+    def change_order_direction(order)
+      order.split(",").collect {|fragment|
+        case fragment
+        when  /\bDESC\b/i     then fragment.gsub(/\bDESC\b/i, "ASC")
+        when  /\bASC\b/i      then fragment.gsub(/\bASC\b/i, "DESC")
+        else                  String.new(fragment).split(',').join(' DESC,') + ' DESC'
+        end
+      }.join(",")
+    end
+
     def recreate_database(name)
       drop_database(name)
       create_database(name)
@@ -259,7 +263,7 @@
       def set_identity_insert(table_name, enable = true)
         execute "SET IDENTITY_INSERT #{table_name} #{enable ? 'ON' : 'OFF'}"
       rescue Exception => e
-        raise ActiveRecordError, "IDENTITY_INSERT could not be turned #{enable ? 'ON' : 'OFF'} for table #{table_name}"
+        raise ActiveRecord::ActiveRecordError, "IDENTITY_INSERT could not be turned #{enable ? 'ON' : 'OFF'} for table #{table_name}"
       end
 
       def get_table_name(sql)
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to