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

Small change to template database initialisation #922

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions newsfragments/914.feature.rst
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
Template databases are now created with is_template flag turned on, and not by setting allow_connections to false.

The allow_connections flag being set to false is used strictly right before we attempt to drop the database.


3 changes: 1 addition & 2 deletions pytest_postgresql/janitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def init(self) -> None:
"""Create database in postgresql."""
with self.cursor() as cur:
if self.is_template():
cur.execute(f'CREATE DATABASE "{self.template_dbname}";')
cur.execute(f'ALTER DATABASE "{self.template_dbname}" with is_template true;')
cur.execute(f'CREATE DATABASE "{self.template_dbname}" WITH is_template = true;')
elif self.template_dbname is None:
cur.execute(f'CREATE DATABASE "{self.dbname}";')
else:
Expand Down
Loading