Skip to content

Commit fc623db

Browse files
authored
Merge pull request #26 from yamashitax/push-lxpvoyvkulrs
fix: pass openssl lib name
2 parents 0e408bd + 616f880 commit fc623db

6 files changed

Lines changed: 32 additions & 41 deletions

File tree

build.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ pub fn build(b: *std.Build) !void {
1616

1717
b.installArtifact(lib);
1818

19-
const pg_dep = b.dependency("pg", .{ .target = target, .optimize = optimize });
19+
const pg_dep = b.dependency("pg", .{
20+
.target = target,
21+
.optimize = optimize,
22+
.openssl_lib_name = "ssl",
23+
});
2024
const jetcommon_dep = b.dependency("jetcommon", .{ .target = target, .optimize = optimize });
2125
const jetcommon_module = jetcommon_dep.module("jetcommon");
2226

src/jetquery/Migrate.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ test "migrate" {
228228

229229
const new_defaults_query = test_repo.Query(.DefaultsTest)
230230
.select(.{ .id, .name, .count });
231-
try std.testing.expectError(error.PG, test_repo.execute(new_defaults_query));
231+
const new_defaults_result = test_repo.execute(new_defaults_query);
232+
try std.testing.expect(new_defaults_result == error.PG);
232233

233234
// Human-cats query should still work after first rollback
234235
var human_cats_result = try test_repo.execute(human_cats_query);
@@ -245,15 +246,16 @@ test "migrate" {
245246
try migrate.rollback();
246247

247248
// After rolling back cats, human table should still exist but can't join to cats
248-
try std.testing.expectError(error.PG, test_repo.execute(human_cats_query));
249+
const human_cats_result2 = test_repo.execute(human_cats_query);
250+
try std.testing.expect(human_cats_result2 == error.PG);
249251

250252
// Rollback the create_humans migration
251253
try migrate.rollback();
252254

253255
// After rolling back humans, human table should no longer exist
254256
{
255257
const humans = test_repo.Query(.Human).all(&test_repo);
256-
try std.testing.expectError(error.PG, humans);
258+
try std.testing.expect(humans == error.PG);
257259
}
258260
}
259261

src/jetquery/Repo.zig

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ test "aggregate count() with HAVING" {
13741374
test "missing config options" {
13751375
try resetDatabase();
13761376

1377-
const repo = Repo(.postgresql, struct {}).init(std.testing.allocator, .{ .adapter = .{} });
1378-
try std.testing.expectError(error.JetQueryConfigError, repo);
1377+
const result = Repo(.postgresql, struct {}).init(std.testing.allocator, .{ .adapter = .{} });
1378+
try std.testing.expect(result == error.JetQueryConfigError);
13791379
}
13801380

13811381
test "transactions" {
@@ -1469,10 +1469,8 @@ test "alterTable" {
14691469

14701470
try repo.createTable("cats", &.{}, .{});
14711471

1472-
try std.testing.expectError(
1473-
error.PG,
1474-
repo.Query(.Cat).select(.{ .name, .paws }).all(&repo),
1475-
);
1472+
const result1 = repo.Query(.Cat).select(.{ .name, .paws }).all(&repo);
1473+
try std.testing.expect(result1 == error.PG);
14761474

14771475
try repo.alterTable("cats", .{
14781476
.columns = .{
@@ -1486,26 +1484,20 @@ test "alterTable" {
14861484
const cats = try repo.Query(.Cat).select(.{ .name, .paws }).all(&repo);
14871485
try std.testing.expect(cats.len == 0); // Empty table but valid select columns.
14881486

1489-
try std.testing.expectError(
1490-
error.PG,
1491-
repo.Query(.Dog).select(.{ .name, .paws }).all(&repo),
1492-
);
1487+
const result2 = repo.Query(.Dog).select(.{ .name, .paws }).all(&repo);
1488+
try std.testing.expect(result2 == error.PG);
14931489

14941490
try repo.alterTable("cats", .{ .rename = "dogs" });
14951491

1496-
try std.testing.expectError(
1497-
error.PG,
1498-
repo.Query(.Cat).select(.{ .name, .paws }).all(&repo),
1499-
);
1492+
const result3 = repo.Query(.Cat).select(.{ .name, .paws }).all(&repo);
1493+
try std.testing.expect(result3 == error.PG);
15001494

15011495
const dogs = try repo.Query(.Dog).select(.{ .name, .paws }).all(&repo);
15021496
try std.testing.expect(dogs.len == 0); // Empty table but valid select columns.
15031497

15041498
try repo.alterTable("dogs", .{ .columns = .{ .drop = &.{"paws"} } });
1505-
try std.testing.expectError(
1506-
error.PG,
1507-
repo.Query(.Dog).select(.{ .name, .paws }).all(&repo),
1508-
);
1499+
const result4 = repo.Query(.Dog).select(.{ .name, .paws }).all(&repo);
1500+
try std.testing.expect(result4 == error.PG);
15091501

15101502
try repo.alterTable(
15111503
"dogs",

src/jetquery/events.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ pub fn defaultCallback(event: Event) !void {
5555
var writer: std.Io.Writer = .fixed(&duration_buf);
5656
try writer.printDurationSigned(duration);
5757
}
58-
const formatted_duration = if (event.duration) |_|
59-
try std.fmt.bufPrint(&buf, " [{s}]", .{duration_buf})
60-
else
61-
"";
58+
const formatted_duration = if (event.duration) |_| blk: {
59+
break :blk std.fmt.bufPrint(&buf, " [{s}]", .{duration_buf}) catch "";
60+
} else "";
6261
std.debug.print("{s}{s}{s}{s}{s}", .{
6362
event.message orelse "",
6463
if (event.message) |_| "\n" else "",

src/jetquery/reflection/util.zig

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,13 @@ pub fn zigEscape(
7070
comptime context: enum { id, string },
7171
input: []const u8,
7272
) ![]const u8 {
73-
var writer: std.Io.Writer.Allocating = .init(allocator);
74-
defer writer.deinit();
73+
var buf = ArrayListManaged(u8).init(allocator);
74+
const writer = buf.writer();
75+
const formatter = switch (context) {
76+
.id => std.zig.fmtId(input),
77+
.string => std.zig.fmtString(input),
78+
};
7579

76-
switch (context) {
77-
.id => {
78-
var formatter = std.zig.fmtId(input);
79-
try formatter.format(&writer.writer);
80-
},
81-
.string => {
82-
try std.zig.stringEscape(input, &writer.writer);
83-
},
84-
}
85-
return writer.toOwnedSlice();
80+
try writer.print("{any}", .{formatter});
81+
return try buf.toOwnedSlice();
8682
}

src/jetquery/sql/Where.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,7 @@ fn nodeTree(
660660
var t: type = OG;
661661

662662
for (path[0 .. path.len - 1]) |c| {
663-
const field_enum = std.meta.FieldEnum(t);
664-
const name_cast = std.enums.nameCast(field_enum, c);
665-
t = @FieldType(t, @tagName(name_cast));
663+
t = @FieldType(t, c);
666664
}
667665
const value: t = undefined;
668666
const condition = @field(value, path[path.len - 1]);

0 commit comments

Comments
 (0)