Skip to content

Move SQL() wrapping to the query definitions #58

@marcelofern

Description

@marcelofern

Current situation:

class MyQueries:

    SWEET_QUERY = "SELECT * FROM {foo};"


# ... later

schema_editor.execute(
    psycopg_sql.SQL(MyQueries.SWEET_QUERY)
    .format(foo=psycopg_sql.Literal(foo))
    .as_string(schema_editor.connection.connection)
)

We can change that so that the SQL wrapper is defined directly in the query
definition

class MyQueries:

    SWEET_QUERY = psycopg_sql.SQL("SELECT * FROM {foo};")

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions