Make inline for loops compatible with stage1

This commit is contained in:
jaina heartles 2022-11-09 16:49:42 -08:00
parent cfdc8c5761
commit 181e57a631
2 changed files with 6 additions and 2 deletions

View file

@ -186,7 +186,9 @@ pub const Db = struct {
var arena = std.heap.ArenaAllocator.init(alloc orelse return error.AllocatorRequired);
defer arena.deinit();
const params = try arena.allocator().alloc(?[*:0]const u8, args.len);
inline for (args) |arg, i| {
//inline for (args) |arg, i| {
inline for (std.meta.fields(@TypeOf(args))) |field, i| {
const arg = @field(args, field.name);
params[i] = if (try common.prepareParamText(&arena, arg)) |slice|
slice.ptr
else

View file

@ -118,7 +118,9 @@ pub const Db = struct {
};
if (@TypeOf(args) != void) {
inline for (args) |arg, i| {
//inline for (args) |arg, i| {
inline for (std.meta.fields(@TypeOf(args))) |field, i| {
const arg = @field(args, field.name);
// SQLite treats $NNN args as having the name NNN, not index NNN.
// As such, if you reference $2 and not $1 in your query (such as
// when dynamically constructing queries), it could assign $2 the