The following patch addresses two issues with the ActiveRecordJDBC
HSQLDB driver:

1. HABTM doesn't work right because hsqldb does not support
java.sql.Statement.execute_update(String,int) -- this is affecting
inserts.  (this fixes issue 11567 on rubyforge --
http://rubyforge.org/tracker/index.php?func=detail&aid=11567&group_id=2014&atid=7857
 )

2. HSQLDB supports boolean columns natively.  ActiveScaffold
(particularly with subforms) was choking (badly) on the default
implementation of 1/0 representing true/false respectively.  By changing
it to boolean, it's not choking any more.  

Now that I'm writing this, I'm wondering whether this change will break
it badly for anyone else using the driver....  I'm thinking that using
the native boolean type is probably the "proper" thing from a database
perspective to do, but I don't know if there are any side effects.
Anyone have any comments?  

Is anyone else using hsqldb?

Matt
Index: jdbc_hsqldb.rb
===================================================================
--- jdbc_hsqldb.rb	(revision 672)
+++ jdbc_hsqldb.rb	(working copy)
@@ -78,7 +78,7 @@
     def modify_types(tp)
       tp[:primary_key] = "INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) PRIMARY KEY"
       tp[:integer][:limit] = nil
-      tp[:boolean][:limit] = nil
+      tp[:boolean] = { :name => "BOOLEAN" }
       # set text and float limits so we don't see odd scales tacked on
       # in migrations
       tp[:text][:limit] = nil
@@ -143,6 +143,18 @@
       Integer(select_value("SELECT IDENTITY() FROM #{table}"))
     end
 
+        def _execute(sql, name = nil)
+      case sql.strip
+      when /\Ainsert/i:
+          insert(sql,name)
+      when /\A\(?\s*(select|show)/i:
+          @connection.execute_query(sql)
+      else
+        @connection.execute_update(sql)
+      end
+    end
+
+    
     def add_limit_offset!(sql, options) #:nodoc:
       offset = options[:offset] || 0
       bef = sql[7..-1]
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to