postgresql-dart icon indicating copy to clipboard operation
postgresql-dart copied to clipboard

Parameterized Query.

Open LibertyBeta opened this issue 5 years ago • 6 comments

So, I might be a little thick, but it seems like this package doesn't use a real parameterized query. For example a query written as: Select * from people where id = $1 where the parameter values are sent separately from the query. Instead we are relying on the escaping of the data in the library. And while this look nice, it still makes me wary.

Will this be supported in the future?

LibertyBeta avatar Mar 02 '20 17:03 LibertyBeta

@LibertyBeta: I think it would be nice to have that, but I'm not aware of anybody wanting to implement it. Do you have any data what it would mean in the query execution performance, or would it provide other features that would be a strong incentive to implement it? Would you be interested in implementing it?

isoos avatar Mar 02 '20 17:03 isoos

Primary feature I can think of is a more standardized way of handling inject and typing. It's not perfect, but very nice.

As to requirements/cost to implement I would have to do some research, consult with people who know more.

Edit: I would require wrapping some work with prepare statements.

LibertyBeta avatar Mar 02 '20 17:03 LibertyBeta

I'm not sure what this issue is in reference to. Prepared statements and parameterized queries are already implemented; this occurs in the backend/frontend protocol communication. I'm not sure if this issue is referring to what is happening, what should be happening?

itsjoeconway avatar Mar 02 '20 18:03 itsjoeconway

@joeconwaystk: some queries still use PostgresTextEncoder (e.g. execute calls), which is probably not the most efficient.

isoos avatar Mar 02 '20 18:03 isoos

Sure, but that is intentional. This issue sounds more a documentation issue?

itsjoeconway avatar Mar 02 '20 18:03 itsjoeconway

I think it might be an issue with the documentation then, as the syntax is different from the use of the PREPARE statement, so typechecking/escaping appears to happen only client side. Maybe something like the docs in node-postgres?

LibertyBeta avatar Mar 02 '20 19:03 LibertyBeta