Title: [589] trunk/activerecord-jdbc/lib: if the statement starts with insert it is definitely an insert so move that check to the top.
Revision
589
Author
tirsen
Date
2007-05-15 19:34:57 -0400 (Tue, 15 May 2007)

Log Message

if the statement starts with insert it is definitely an insert so move that check to the top. this is a bit unstable isnt there another way to do it?

Modified Paths

Diff

Modified: trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb (588 => 589)


--- trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb	2007-05-15 17:49:58 UTC (rev 588)
+++ trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb	2007-05-15 23:34:57 UTC (rev 589)
@@ -411,10 +411,10 @@
       def _execute(sql, name = nil)
         log_no_bench(sql, name) do
           case sql.strip
-          when /^(select|show)/i:
-              @connection.execute_query(sql)
           when /^insert/i:
-              @connection.execute_insert(sql)
+            @connection.execute_insert(sql)
+          when /^\(?\s*(select|show)/i:
+            @connection.execute_query(sql)
           else
             @connection.execute_update(sql)
           end

Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb (588 => 589)


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-15 17:49:58 UTC (rev 588)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-15 23:34:57 UTC (rev 589)
@@ -124,6 +124,8 @@
     def _execute(sql, name = nil)
       log_no_bench(sql, name) do
         case sql.strip
+        when /^insert/i:
+          @connection.execute_insert(sql)
         when /^\(?\s*(select|show)/i:
           @offset ||= 0
           if [EMAIL PROTECTED] || @limit == -1
@@ -134,8 +136,6 @@
             max = @[EMAIL PROTECTED]
           end
           @connection.execute_query(sql,max)[range] || []
-        when /^insert/i:
-          @connection.execute_insert(sql)
         else
           @connection.execute_update(sql)
         end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to