Skip to content

Conversation

@dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Oct 18, 2025

Helpers for prefixed databases

Tested on canonical/postgresql-operator#1238

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.99%. Comparing base (6748b7c) to head (bc0195a).
⚠️ Report is 1 commits behind head on 16/edge.

Files with missing lines Patch % Lines
single_kernel_postgresql/utils/postgresql.py 95.23% 1 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (48.99%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           16/edge      #27      +/-   ##
===========================================
+ Coverage    46.72%   48.99%   +2.27%     
===========================================
  Files            4        4              
  Lines          809      849      +40     
  Branches        94       98       +4     
===========================================
+ Hits           378      416      +38     
- Misses         414      415       +1     
- Partials        17       18       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

user_definition += f" IN ROLE {', '.join(str_roles)}"
return user_definition, connect_statements

def _adjust_user_roles(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split off from _adjust_user_definition() so that we can get just the roles.

Comment on lines +1886 to +1888
def add_user_to_databases(
self, user: str, databases: List[str], extra_user_roles: Optional[List[str]] = None
) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we don't alter the user, just add roles and connect privs.

@dragomirp dragomirp marked this pull request as ready for review October 20, 2025 15:41
@dragomirp dragomirp requested review from a team, marceloneppel and taurus-forever and removed request for a team October 20, 2025 15:41
@dragomirp dragomirp requested a review from paulomach October 21, 2025 13:49
db_roles, db_connect_stmt = self._adjust_user_roles(user, roles, database)
roles += db_roles
connect_stmt += db_connect_stmt
with self._connect_to_database() as connection, connection.cursor() as cursor:

Choose a reason for hiding this comment

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

unrelated and out of curiosity, why not add commit control on the context manager, as a parameter of connection.cursor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Likely copy paste momentum. We should overhaul and move to psycopg3 in general.

Copy link

@paulomach paulomach left a comment

Choose a reason for hiding this comment

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

lgtm. unrelated comment

@dragomirp dragomirp merged commit af95bb2 into 16/edge Oct 23, 2025
6 of 7 checks passed
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.

4 participants