diff --git a/.travis.yml b/.travis.yml index 4fc3543..bd585c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ rvm: - 1.9.3 - 2.0.0 - rbx-2 + - jruby gemfile: - Gemfile diff --git a/activeuuid.gemspec b/activeuuid.gemspec index 0c2f088..61e5ec6 100644 --- a/activeuuid.gemspec +++ b/activeuuid.gemspec @@ -23,9 +23,17 @@ Gem::Specification.new do |s| s.add_development_dependency "database_cleaner" s.add_development_dependency "forgery" s.add_development_dependency "fabrication" - s.add_development_dependency "sqlite3" - s.add_development_dependency "pg" - s.add_development_dependency "mysql2" + + if RUBY_PLATFORM == 'java' + s.add_development_dependency "activerecord-jdbc-adapter" + s.add_development_dependency "activerecord-jdbcmysql-adapter" + s.add_development_dependency "activerecord-jdbcpostgresql-adapter" + s.add_development_dependency "activerecord-jdbcsqlite3-adapter" + else + s.add_development_dependency "mysql2" + s.add_development_dependency "sqlite3" + s.add_development_dependency "pg" + end s.add_runtime_dependency "uuidtools" s.add_runtime_dependency "activerecord", '>= 3.1' diff --git a/lib/activeuuid/patches.rb b/lib/activeuuid/patches.rb index 1a28db4..f154092 100644 --- a/lib/activeuuid/patches.rb +++ b/lib/activeuuid/patches.rb @@ -14,6 +14,19 @@ def uuid(*column_names) end end + module JdbcMySQLSimplifiedType + extend ActiveSupport::Concern + + included do + def simplified_type_with_mysqljdbc(field_type) + return :uuid if field_type == 'binary(16)' + simplified_type_without_mysqljdbc(field_type) + end + + alias_method_chain :simplified_type, :mysqljdbc + end + end + module Column extend ActiveSupport::Concern @@ -118,6 +131,12 @@ def self.apply! ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, PostgreSQLQuoting if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter + + if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter + ActiveRecord::ConnectionAdapters::MysqlAdapter.send :include, Quoting + ActiveRecord::ConnectionAdapters::MysqlAdapter::Column.send :include, Column + ArJdbc::MySQL::Column.send :include, JdbcMySQLSimplifiedType + end end end end