This is for create_table --
hsql supports a number of table types beyond temporary (mem, cached,
etc.). You can set a global property which will set the default table
type (by default, tables are stored in memory), but it might be useful
to be able to specify the table type on a table-by-table basis. Hence
this patch.
Enjoy!
---- cut here -----
Index: jdbc_hsqldb.rb
===================================================================
--- jdbc_hsqldb.rb (revision 611)
+++ jdbc_hsqldb.rb (working copy)
@@ -93,6 +93,35 @@
'0'
end
+ # hsqldb has more than one type of table; some are purely memory
+ # resident whereas others are cached, etc...
+ # see http://hsqldb.org/doc/guide/ch09.html#create_table-section
+ # for more details
+ def create_table(name, options = {})
+ table_definition =
ActiveRecord::ConnectionAdapters::TableDefinition.new(self)
+ table_definition.primary_key(options[:primary_key] || "id")
unless options[:id] == false
+
+ yield table_definition
+
+ if options[:force]
+ drop_table(name, options) rescue nil
+ end
+
+
+ create_sql = "CREATE"
+ create_sql << " GLOBAL" if options[:global]
+ create_sql << " TEMPORARY" if (options[:temporary] ||
options[:temp])
+ create_sql << " MEM" if options[:mem]
+ create_sql << " CACHED" if options[:cached]
+ create_sql << " TEXT" if options[:text]
+ create_sql << " TABLE "
+ create_sql << "#{name} ("
+ create_sql << table_definition.to_sql
+ create_sql << ") #{options[:options]}"
+ execute create_sql
+ end
+
+
def change_column(table_name, column_name, type, options = {})
#:nodoc:
execute "ALTER TABLE #{table_name} ALTER COLUMN #{column_name}
#{type_to_sql(type, options[:limit])}"
end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel