Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jdbc mysql #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
- DB=sqlite3
- DB=mysql
- DB=postgresql
- DB=jdbc-mysql

matrix:
allow_failures:
Expand Down
19 changes: 19 additions & 0 deletions lib/activeuuid/patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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