SQL string runtime allocation is no more needed since the prefix is now always comptime-known.
This commit is contained in:
parent
97c4c429e1
commit
21a2e88295
1 changed files with 10 additions and 10 deletions
|
@ -112,18 +112,18 @@ pub fn typedMany(
|
||||||
.through => |through| {
|
.through => |through| {
|
||||||
// Add SELECT.
|
// Add SELECT.
|
||||||
query.select(.{
|
query.select(.{
|
||||||
.sql = try std.fmt.allocPrint(query.arena.allocator(), baseSelect ++ ", \"{s}pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\" AS \"__zrm_relation_key\"", .{prefix}),
|
.sql = baseSelect ++ ", \"" ++ prefix ++ "pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\" AS \"__zrm_relation_key\"",
|
||||||
.params = &[0]_sql.RawQueryParameter{},
|
.params = &[0]_sql.RawQueryParameter{},
|
||||||
});
|
});
|
||||||
|
|
||||||
query.join(.{
|
query.join(.{
|
||||||
.sql = try std.fmt.allocPrint(query.arena.allocator(), "INNER JOIN \"" ++ through.table ++ "\" ON AS \"{s}pivot" ++ "\" " ++
|
.sql = "INNER JOIN \"" ++ through.table ++ "\" ON AS \"" ++ prefix ++ "pivot" ++ "\" " ++
|
||||||
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = " ++ "\"{s}pivot" ++ "\"." ++ through.joinModelKey, .{prefix, prefix}),
|
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = " ++ "\"" ++ prefix ++ "pivot" ++ "\"." ++ through.joinModelKey,
|
||||||
.params = &[0]_sql.RawQueryParameter{},
|
.params = &[0]_sql.RawQueryParameter{},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build WHERE condition.
|
// Build WHERE condition.
|
||||||
try query.whereIn(FromKeyType, try std.fmt.allocPrint(query.arena.allocator(), "\"{s}pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\"", .{prefix}), modelsIds);
|
try query.whereIn(FromKeyType, "\"" ++ prefix ++ "pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\"", modelsIds);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,8 +289,8 @@ fn typedOne(
|
||||||
});
|
});
|
||||||
|
|
||||||
query.join((_sql.RawQuery{
|
query.join((_sql.RawQuery{
|
||||||
.sql = try std.fmt.allocPrint(query.arena.allocator(), "INNER JOIN \"" ++ fromRepositoryConfig.table ++ "\" AS \"{s}related" ++ "\" ON " ++
|
.sql = "INNER JOIN \"" ++ fromRepositoryConfig.table ++ "\" AS \"" ++ prefix ++ "related" ++ "\" ON " ++
|
||||||
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = \"{s}related" ++ "\"." ++ foreignKey, .{prefix, prefix}),
|
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = \"" ++ prefix ++ "related" ++ "\"." ++ foreignKey,
|
||||||
.params = &[0]_sql.RawQueryParameter{},
|
.params = &[0]_sql.RawQueryParameter{},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -310,18 +310,18 @@ fn typedOne(
|
||||||
.through => |through| {
|
.through => |through| {
|
||||||
// Add SELECT.
|
// Add SELECT.
|
||||||
query.select(.{
|
query.select(.{
|
||||||
.sql = try std.fmt.allocPrint(query.arena.allocator(), baseSelect ++ ", \"{s}pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\" AS \"__zrm_relation_key\"", .{prefix}),
|
.sql = baseSelect ++ ", \"" ++ prefix ++ "pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\" AS \"__zrm_relation_key\"",
|
||||||
.params = &[0]_sql.RawQueryParameter{},
|
.params = &[0]_sql.RawQueryParameter{},
|
||||||
});
|
});
|
||||||
|
|
||||||
query.join(.{
|
query.join(.{
|
||||||
.sql = try std.fmt.allocPrint(query.arena.allocator(), "INNER JOIN \"" ++ through.table ++ "\" AS \"{s}pivot" ++ "\" ON " ++
|
.sql = "INNER JOIN \"" ++ through.table ++ "\" AS \"" ++ prefix ++ "pivot" ++ "\" ON " ++
|
||||||
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = " ++ "\"{s}pivot" ++ "\"." ++ through.joinModelKey, .{prefix, prefix}),
|
"\"" ++ toRepositoryConfig.table ++ "\"." ++ modelKey ++ " = " ++ "\"" ++ prefix ++ "pivot" ++ "\"." ++ through.joinModelKey,
|
||||||
.params = &[0]_sql.RawQueryParameter{},
|
.params = &[0]_sql.RawQueryParameter{},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build WHERE condition.
|
// Build WHERE condition.
|
||||||
try query.whereIn(FromKeyType, try std.fmt.allocPrint(query.arena.allocator(), "\"{s}pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\"", .{prefix}), modelsIds);
|
try query.whereIn(FromKeyType, "\"" ++ prefix ++ "pivot" ++ "\".\"" ++ through.joinForeignKey ++ "\"", modelsIds);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue