Skip to content

Commit

Permalink
Compatibility with ArJdbc > 1.3.12. Fix SchemaPlus#214
Browse files Browse the repository at this point in the history
  • Loading branch information
lfidnl committed Jul 25, 2015
1 parent 953fdc1 commit 9f258a3
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def convert_default_value(default, value)
# The Postgresql adapter implements the SchemaPlus extensions and
# enhancements
module PostgresqlAdapter
def self.arjdbc_patch_version_greater_12?
defined?(ArJdbc::VERSION) && ArJdbc::VERSION.match(/1.3.(\d*)/)[1].to_i > 12
end
private_class_method :arjdbc_patch_version_greater_12?

if arjdbc_patch_version_greater_12?
module ::ActiveRecord::ConnectionAdapters
remove_const(:PostgreSQLColumn) if const_defined?(:PostgreSQLColumn)
class PostgreSQLColumn < JdbcColumn; end
end
end

def self.included(base) #:nodoc:
base.class_eval do
Expand All @@ -75,6 +86,7 @@ def self.included(base) #:nodoc:
alias_method_chain :exec_cache, :schema_plus unless defined?(JRUBY_VERSION)
end
::ActiveRecord::ConnectionAdapters::PostgreSQLColumn.send(:include, PostgreSQLColumn) unless ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn.include?(PostgreSQLColumn)
::ActiveRecord::ConnectionAdapters::PostgreSQLColumn.send(:include, ::ArJdbc::PostgreSQL::Column) if arjdbc_patch_version_greater_12?
end

# SchemaPlus provides the following extra options for PostgreSQL
Expand Down

0 comments on commit 9f258a3

Please sign in to comment.