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

Refactor BaseDatabase class for simplicity #945

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Oct 17, 2024

This aims to make the BaseDatabase class easier to follow. At this point it's untested, but it was inspired by #939. At this point it's untested and not everything may make sense. It's structured as smaller commits that should be fairly straight forward to follow.

evgeni and others added 13 commits October 17, 2024 17:30
The configuration is an instance level setting that is never passed in.
This simplifies the code by avoiding the need to pass it around.
This avoids needing to use a shell.
This avoids the need to build a complex command. On the plus side, it
avoids the risk of leaking anything about the database access. On the
downside, that can make debugging harder.
This avoids the need for another helper command and simplifies the
commands.
This matches other queries.
This uses a block that won't run if @deb_postgresql_versions is already
set.
This wasn't used in the past for Ruby 1.9 or 2.0 support, but we can now
rely on this. It makes testing easier.
'PGHOST' => configuration.fetch('host', 'localhost'),
'PGPORT' => configuration.fetch('port', '5432'),
'PGUSER' => configuration.fetch('username'),
'PGPASSWORD' => configuration[%(password)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'PGPASSWORD' => configuration[%(password)],
'PGPASSWORD' => configuration['password'],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept that from the previous implementation, but I agree that if we focus on simplicity that we should also apply it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There it was just to escape (lol) quoting hell because of

"PGPASSWORD='#{config[%(password)]}' "

Here it's just weird :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants