summaryrefslogtreecommitdiff
path: root/src/duckdb/db.zig
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-08-02 13:23:21 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-08-03 13:44:49 +0200
commitdabbb107d719cb753673e394fbd4da090f74d458 (patch)
tree1beba6ec67922882db0cf6606d712195dcfb62d1 /src/duckdb/db.zig
parentf225c34d82cb6ea4133af64c34f977be00769afc (diff)
WIP String queries and proper conversion:
Still have to make the type checking better, not just an assert. Rethink.
Diffstat (limited to 'src/duckdb/db.zig')
-rw-r--r--src/duckdb/db.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/duckdb/db.zig b/src/duckdb/db.zig
index 19feffe..f662ee0 100644
--- a/src/duckdb/db.zig
+++ b/src/duckdb/db.zig
@@ -109,3 +109,31 @@ test "Checks if all fields are captured" {
try std.testing.expectError(error.QueryColumnCountCapture,
connection.query("SELECT * FROM integers;", s));
}
+
+test "String queries" {
+ var database = try Database.init(":memory:");
+ defer database.deinit();
+ var connection = try database.connect();
+ defer connection.deinit();
+
+ const s : type = comptime struct {
+ primer: []const u8
+ };
+
+ var x = try connection.query("CREATE TABLE text (i VARCHAR NOT NULL );", void);
+ x.deinit();
+ var y = try connection.query("INSERT INTO text VALUES ('Inlined');", void);
+ y.deinit();
+ var z = try connection.query("INSERT INTO text VALUES ('A very long string that is not inlined');", void);
+ z.deinit();
+ var result = try connection.query("SELECT * FROM text;", s);
+ defer result.deinit();
+
+
+ try std.testing.expect(1 == result.getColumnCount());
+
+ var w = try result.next();
+ try std.testing.expect(std.mem.eql(u8, w.primer, "Inlined"));
+ w = try result.next();
+ try std.testing.expect(std.mem.eql(u8, w.primer, "A very long string that is not inlined"));
+}