summaryrefslogtreecommitdiff
path: root/src/duckdb/Database.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/duckdb/Database.zig')
-rw-r--r--src/duckdb/Database.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/duckdb/Database.zig b/src/duckdb/Database.zig
index ffdd052..8a34696 100644
--- a/src/duckdb/Database.zig
+++ b/src/duckdb/Database.zig
@@ -175,3 +175,31 @@ test "Prepared queries" {
r = try result.next();
try std.testing.expect(r.primer == dos);
}
+
+test "Prepared queries with strings" {
+ var database = try Self.init(":memory:");
+ defer database.deinit();
+ var connection = try database.connect();
+ defer connection.deinit();
+
+ try connection.run("CREATE TABLE ints (i STRING NOT NULL );");
+ var prepared = try connection.prepareStatement("INSERT INTO ints VALUES (?), (?);");
+ defer prepared.deinit();
+
+ const uno = "1";
+ const dos = "2";
+ try prepared.bindAll(.{uno, dos});
+ var res = try prepared.exec(void);
+ res.deinit();
+
+ const s: type = struct {
+ primer: []const u8,
+ };
+ var result = try connection.query("SELECT * FROM ints;", s);
+ defer result.deinit();
+
+ var w = try result.next();
+ try std.testing.expect(std.mem.eql(u8, w.primer, "1"));
+ w = try result.next();
+ try std.testing.expect(std.mem.eql(u8, w.primer, "2"));
+}