You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the DjangoDebugMiddleware, Graphene Django wraps cursor.execute calls in a class that logs the query. Among the properties it logs is is_select, which attempts to guess if a query is a select query by looking for "select" in the argument to cursor.execute:
When cursor.execute is called with a non-string argument, such as a psycopg2 query template, this raises an error:
fromdjango.dbimportconnectionfrompsycopg2importsqlwithconnection.cursor() ascursor:
query=sql.SQL("SELECT * FROM {table}").format(table=sql.Identifier("my_table"))
cursor.execute(query)
This raises:
graphql.error.located_error.GraphQLLocatedError: 'Composed' object has no attribute 'lower'
What is the expected behavior?
Grahene Django should not presume that the argument to connection.cursor() will always be a string, and do appropriate string coercion as needed before calling string methods on it.
What is the motivation / use case for changing the behavior?
Robustness. It's ideal not to throw exceptions from normal uses of core Django methods which graphene-django monkeypatches.
Please tell us about your environment:
Version: graphene-django 2.5.0
Platform: Ubuntu Linux 18.04, Django 2.2.12, graphene 2.1.8