On Wed, 18 Dec 2013 15:54:38 GMT, Luís Marques wrote:

On Tue, 17 Dec 2013 20:43:02 GMT, Luís Marques wrote:

I have ddb working, but I don't know how to pass parameters to queries (without concatenating strings, which is unsafe and awkward). That is, I'm looking for something like this:

PGCommand(conn, "SELECT * FROM foo WHERE bar = ?", barValue);

I had missed the right part of the source (I couldn't get dmd -D to work for postgres.d) where it says:

Examples:
---
// without spaces between $ and number
auto cmd = new PGCommand(conn, "INSERT INTO users (name, surname) VALUES ($ 1, $ 2)");
cmd.parameters.add(1, PGType.TEXT).value = "John";
cmd.parameters.add(2, PGType.TEXT).value = "Doe";

I had expected that one could pass the params directly in the ctor, like in my example.

I'd also open up an issue on github, Piotr may not be active enough here in the forum to see it.

But I agree with that sentiment, at least in a D API I'd expect that, too. Maybe even statically checked for validity with something like

auto cmd = makePGCommand!"INSERT INTO users (name, surname) VALUES ($1, $2)"("John", "Doe");