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

Bdaniels/hotfix #531

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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 CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2023-12-08 (5.19.2)

* Bugfix: Used pyscopg.sql instead of psycopg2.sql for compatability

# 2023-12-05 (5.19.1)

* Updated Django version > 4.2
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = amsterdam-schema-tools
version = 5.19.1
version = 5.19.2
url = https://github.com/amsterdam/schema-tools
license = Mozilla Public 2.0
author = Team Data Diensten, van het Dataplatform onder de Directie Digitale Voorzieningen (Gemeente Amsterdam)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.core.management import BaseCommand, CommandError
from django.db import DatabaseError, connection, transaction
from psycopg2 import sql
from psycopg import sql

from schematools.contrib.django.models import Dataset, DatasetTableSchema
from schematools.naming import to_snake_case
Expand Down Expand Up @@ -96,18 +96,18 @@ def _clean_sql(sql) -> str:
return sql


def _create_role_if_not_exists(cursor, role_name):
# Create the role if it doesn't exist
def _create_role_if_not_exists(cursor, user_role_name):
""" Create the role if it doesn't exist """
cursor.execute(
sql.SQL("SELECT 1 FROM pg_roles WHERE rolname={role_name}").format(
role_name=sql.Literal(role_name)
role_name=sql.Literal(user_role_name)
)
)

role_exists = cursor.fetchone()
if not role_exists:
cursor.execute(
sql.SQL("CREATE ROLE {role_name}").format(role_name=sql.Identifier(role_name))
sql.SQL("CREATE ROLE {role_name}").format(role_name=sql.Identifier(user_role_name))
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core.management import BaseCommand, CommandError
from django.db import connection
from django.db.utils import ProgrammingError
from psycopg2 import sql
from psycopg import sql

from schematools.contrib.django.models import Dataset, DatasetTable
from schematools.naming import to_snake_case
Expand Down
Loading