diff options
Diffstat (limited to 'src/duckdb/db.zig')
-rw-r--r-- | src/duckdb/db.zig | 28 |
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")); +} |