Skip to content

Commit

Permalink
chore: use pattern match for detecting postgres database [pf]
Browse files Browse the repository at this point in the history
Allow custom IAM Postgres database to be correctly recognised as postgres
  • Loading branch information
bethesque committed Feb 15, 2022
1 parent 49c0476 commit 5414786
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion db/migrations/migration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def mysql?
end

def postgres?
adapter == "postgres"
adapter =~ /postgres/
end

def adapter
Expand Down
2 changes: 1 addition & 1 deletion lib/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def self.mysql?
end

def self.postgres?
!!(PACT_BROKER_DB.adapter_scheme.to_s == "postgres")
!!(PACT_BROKER_DB.adapter_scheme.to_s =~ /postgres/)
end

PACT_BROKER_DB ||= connection_for_env ENV.fetch("RACK_ENV")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def database_connection_validation_timeout= database_connection_validation_timeo
end

def postgres?
database_credentials[:adapter] == "postgres"
database_credentials[:adapter] =~ /postgres/
end
private :postgres?

Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/repositories/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def mysql?
end

def postgres?
Sequel::Model.db.adapter_scheme.to_s == "postgres"
Sequel::Model.db.adapter_scheme.to_s =~ /postgres/
end

def select_all_qualified
Expand Down
2 changes: 1 addition & 1 deletion lib/sequel/plugins/upsert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def mysql?
end

def postgres?
model.db.adapter_scheme.to_s == "postgres"
model.db.adapter_scheme.to_s =~ /postgres/
end

def values_to_update
Expand Down
2 changes: 1 addition & 1 deletion tasks/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def ensure_not_production
end

def psql?
adapter == "postgres"
adapter =~ /postgres/
end

def sqlite?
Expand Down

0 comments on commit 5414786

Please sign in to comment.