liberapay/postgres.py

use kwargs for bind params

Closed this issue · 3 comments

Suggested by @dstufft in IRC.

We currently pass kwargs through to the cursor constructor. How would we handle that instead? Make some kwargs magic (eep!)?

I really want this.

I would rather pass nothing at all, pulling values directly from locals and globals instead. Unfortunately PEP 498 didn't take into account the need for escaping so we can't use f-strings for SQL.

Update on October 1st, 2019: It has occurred to me that we probably don't need any new special support in the interpreter to be able to automatically pull values from locals and globals, we should be able to walk up the stack and access the context of the calling function. However it probably wouldn't be very efficient, so we might as well just pass locals() as the query parameters.

Done in #79.