Permalink
Browse files

Added switch for class in JRuby case

  • Loading branch information...
dpayonk committed Feb 20, 2013
1 parent c59216c commit f357f758d2784b81625c3e7db68280072bb01e2f
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/activerecord-postgres-hstore/activerecord.rb
@@ -66,9 +66,11 @@ def destroy_keys! attribute, *keys
end
end
+
module ConnectionAdapters
+ #I believe this change will break the ability to do a schema dump as per issue #83
+ #https://github.com/engageis/activerecord-postgres-hstore/commit/ca34391c776949c13d561870067ddf581f0561b9#lib/activerecord-postgres-hstore/activerecord.rb
if(RUBY_PLATFORM != 'java')
-
class PostgreSQLColumn < Column
# Adds the hstore type for the column.
def simplified_type_with_hstore(field_type)
@@ -83,6 +85,23 @@ def native_database_types_with_hstore
native_database_types_without_hstore.merge({:hstore => { :name => "hstore" }})
end
+ alias_method_chain :native_database_types, :hstore
+ end
+ else
+ class PostgreSQLColumn
+ # Adds the hstore type for the column.
+ def simplified_type_with_hstore(field_type)
+ field_type == 'hstore' ? :hstore : simplified_type_without_hstore(field_type)
+ end
+
+ alias_method_chain :simplified_type, :hstore
+ end
+
+ class PostgreSQLAdapter
+ def native_database_types_with_hstore
+ native_database_types_without_hstore.merge({:hstore => { :name => "hstore" }})
+ end
+
alias_method_chain :native_database_types, :hstore
end
end

0 comments on commit f357f75

Please sign in to comment.