Add execWithOptions

This commit is contained in:
jaina heartles 2022-12-07 01:57:07 -08:00
parent 9f0cac0ed3
commit d4cd0e6618

View file

@ -543,7 +543,16 @@ fn Tx(comptime tx_level: u8) type {
args: anytype, args: anytype,
alloc: ?std.mem.Allocator, alloc: ?std.mem.Allocator,
) !void { ) !void {
try self.execInternal(sql, args, alloc, true); try self.execInternal(sql, args, .{ .allocator = alloc }, true);
}
pub fn execWithOptions(
self: Self,
sql: [:0]const u8,
args: anytype,
options: QueryOptions,
) !void {
try self.execInternal(sql, args, options, true);
} }
pub fn queryWithOptions( pub fn queryWithOptions(
@ -699,17 +708,17 @@ fn Tx(comptime tx_level: u8) type {
self: Self, self: Self,
sql: [:0]const u8, sql: [:0]const u8,
args: anytype, args: anytype,
alloc: ?std.mem.Allocator, options: QueryOptions,
comptime check_tx: bool, comptime check_tx: bool,
) !void { ) !void {
var results = try self.runSql(sql, args, .{ .allocator = alloc }, check_tx); var results = try self.runSql(sql, args, options, check_tx);
defer results.finish(); defer results.finish();
while (try results.row()) |_| {} while (try results.row()) |_| {}
} }
fn rollbackUnchecked(self: Self) !void { fn rollbackUnchecked(self: Self) !void {
try self.execInternal("ROLLBACK", {}, null, false); try self.execInternal("ROLLBACK", {}, .{}, false);
} }
}; };
} }