Deinitialize the query result and release the connection as soon as possible.

This commit is contained in:
Madeorsk 2024-10-17 13:04:15 +02:00
parent a13949ca4d
commit 5b9cfd08c4
Signed by: Madeorsk
GPG key ID: 677E51CA765BB79F
3 changed files with 6 additions and 3 deletions

View file

@ -299,7 +299,8 @@ pub fn RepositoryInsert(comptime Model: type, comptime TableShape: type, comptim
if (self.sql) |_| {} else { try self.buildSql(); } if (self.sql) |_| {} else { try self.buildSql(); }
// Execute query and get its result. // Execute query and get its result.
const queryResult = try self.execQuery(); var queryResult = try self.execQuery();
defer queryResult.deinit();
//TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed. //TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed.
//TODO make a generic mapper and do it in repository.zig? //TODO make a generic mapper and do it in repository.zig?

View file

@ -216,7 +216,8 @@ pub fn RepositoryQuery(comptime Model: type, comptime TableShape: type, comptime
if (self.sql) |_| {} else { try self.buildSql(); } if (self.sql) |_| {} else { try self.buildSql(); }
// Execute query and get its result. // Execute query and get its result.
const queryResult = try self.execQuery(); var queryResult = try self.execQuery();
defer queryResult.deinit();
//TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed. //TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed.
//TODO make a generic mapper and do it in repository.zig? //TODO make a generic mapper and do it in repository.zig?

View file

@ -303,7 +303,8 @@ pub fn RepositoryUpdate(comptime Model: type, comptime TableShape: type, comptim
if (self.sql) |_| {} else { try self.buildSql(); } if (self.sql) |_| {} else { try self.buildSql(); }
// Execute query and get its result. // Execute query and get its result.
const queryResult = try self.execQuery(); var queryResult = try self.execQuery();
defer queryResult.deinit();
//TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed. //TODO deduplicate this in postgresql.zig, we could do it if Mapper type was exposed.
//TODO make a generic mapper and do it in repository.zig? //TODO make a generic mapper and do it in repository.zig?