vrischmann / zig-sqlite

zig-sqlite is a small wrapper around sqlite's C API, making it easier to use with Zig.
MIT License
367 stars 49 forks source link

exec expects two arguments, but README only lists one argument. #140

Closed OrganicProgramming closed 11 months ago

OrganicProgramming commented 11 months ago

zig-sqlite commit

19535aa

Zig version

0.11.0

Steps to reproduce

statement.exec needs extra argument, e.g. code in README does not work this way:

const query =
    \\UPDATE foo SET salary = ? WHERE id = ?
;

var stmt = try db.prepare(query);
defer stmt.deinit();

try stmt.exec(.{
    .salary = 20000,
    .id = 40,
});

but it works if an empty struct is added as the first argument to exec

const query =
    \\UPDATE foo SET salary = ? WHERE id = ?
;

var stmt = try db.prepare(query);
defer stmt.deinit();

try stmt.exec(.{}, .{
    .salary = 20000,
    .id = 40,
});

Expected behaviour

According to the README, the exec function of a prepared statement takes only one argument. So either the README should be modified for all occurrences of the exec function or the API should be changed.

vrischmann commented 11 months ago

You're right, thanks for the report