arcapos / luapgsql

Lua binding for PostgreSQL
108 stars 24 forks source link

Named parameters in query #55

Closed d9k closed 3 years ago

d9k commented 5 years ago

(for readability)

see https://github.com/brianc/node-postgres/issues/268

daurnimator commented 5 years ago

This is tremendously hard to get correct. Postgres does not support this. @mbalmer I recommend closing as wontfix

d9k commented 5 years ago

@daurnimator, to do it right we need to parse postgresql query to syntax tree and there are some ways to do it:

https://wiki.postgresql.org/wiki/Query_Parsing

I agree that it's an advanced functionality beyond the purpose of luapgsql library

d9k commented 5 years ago

@daurnimator, @mbalmer, but php has named arguments support in pdo statements for many years. http://php.net/manual/en/pdo.prepared-statements.php

Or is their solution lack reliability too?

daurnimator commented 5 years ago

Or is their solution lack reliability too?

Correct. To use the named parameters, PDO emulates prepared statements client side. This uses their general SQL parser pdo_parse_params, which doesn't understand all postgres statements.

mbalmer commented 3 years ago

As daurnimator recommends, we won't do this.