-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConnectionAdapter with check_version overriding
New OvirtPostgreSQLAdapter that extends the default one adding a check_version method to override restrictions imposed by the manageiq postgresql_required_versions initializer. This modification, with the update of the initializer mentioned above should solve: https://bugzilla.redhat.com/show_bug.cgi?id=1734770
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
lib/active_record/connection_adapters/ovirt_postgresql_adapter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module ActiveRecord | ||
module ConnectionHandling # :nodoc: | ||
def ovirt_postgresql_connection(config) | ||
conn_params = config.symbolize_keys | ||
|
||
conn_params.delete_if { |_, v| v.nil? } | ||
|
||
conn_params[:user] = conn_params.delete(:username) if conn_params[:username] | ||
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database] | ||
|
||
valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl] | ||
conn_params.slice!(*valid_conn_param_keys) | ||
|
||
ConnectionAdapters::OvirtPostgreSQLAdapter.new(nil, logger, conn_params, config) | ||
end | ||
end | ||
|
||
module ConnectionAdapters | ||
class OvirtPostgreSQLAdapter < PostgreSQLAdapter | ||
ADAPTER_NAME = "OvirtPostgreSQL" | ||
|
||
def check_version | ||
msg = "The version of PostgreSQL (#{postgresql_version}) is too old (9.2+ required)" | ||
if postgresql_version < 90200 | ||
raise msg | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters