From fa2ab7212d5514e797698c18bac09cae9addc63d Mon Sep 17 00:00:00 2001 From: Ilan Uzan Date: Sat, 20 Dec 2025 23:48:05 +0100 Subject: [PATCH 1/2] fix: GetIdColumnType bugfix --- Drivers/DbDriver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Drivers/DbDriver.cs b/Drivers/DbDriver.cs index c55e2b7d..b111eaea 100644 --- a/Drivers/DbDriver.cs +++ b/Drivers/DbDriver.cs @@ -280,11 +280,11 @@ this method uses a few heuristics to assess the data type of the id column public string GetIdColumnType(Query query) { var tableColumns = Tables[query.InsertIntoTable.Schema][query.InsertIntoTable.Name].Columns; - var idColumn = tableColumns.First(c => c.Name.Equals("id", StringComparison.OrdinalIgnoreCase)); + var idColumn = tableColumns.FirstOrDefault(c => c.Name.Equals("id", StringComparison.OrdinalIgnoreCase)); if (idColumn is not null) return GetCsharpType(idColumn, query); - idColumn = tableColumns.First(c => c.Name.Contains("id", StringComparison.CurrentCultureIgnoreCase)); + idColumn = tableColumns.FirstOrDefault(c => c.Name.Contains("id", StringComparison.CurrentCultureIgnoreCase)); return GetCsharpType(idColumn ?? tableColumns[0], query); } From 2ec5ba96c07947aa631efa891e0b0fe33a99b660 Mon Sep 17 00:00:00 2001 From: Ilan Uzan Date: Sun, 21 Dec 2025 12:02:11 +0100 Subject: [PATCH 2/2] fix: add indication of in which query an exception was thrown --- CodeGenerator/Generators/QueriesGen.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/CodeGenerator/Generators/QueriesGen.cs b/CodeGenerator/Generators/QueriesGen.cs index 65893286..99559061 100644 --- a/CodeGenerator/Generators/QueriesGen.cs +++ b/CodeGenerator/Generators/QueriesGen.cs @@ -183,15 +183,22 @@ private MemberDeclarationSyntax AddMethodDeclaration(Query query) var argInterface = ClassMember.Args.Name(query.Name); var returnInterface = ClassMember.Row.Name(query.Name); - return query.Cmd switch + try { - ":exec" => ((IExec)dbDriver).ExecDeclare(queryTextConstant, argInterface, query), - ":one" => ((IOne)dbDriver).OneDeclare(queryTextConstant, argInterface, returnInterface, query), - ":many" => ((IMany)dbDriver).ManyDeclare(queryTextConstant, argInterface, returnInterface, query), - ":execrows" => ((IExecRows)dbDriver).ExecRowsDeclare(queryTextConstant, argInterface, query), - ":execlastid" => ((IExecLastId)dbDriver).ExecLastIdDeclare(queryTextConstant, argInterface, query), - ":copyfrom" => ((ICopyFrom)dbDriver).CopyFromDeclare(queryTextConstant, argInterface, query), - _ => throw new NotSupportedException($"{query.Cmd} is not supported") - }; + return query.Cmd switch + { + ":exec" => ((IExec)dbDriver).ExecDeclare(queryTextConstant, argInterface, query), + ":one" => ((IOne)dbDriver).OneDeclare(queryTextConstant, argInterface, returnInterface, query), + ":many" => ((IMany)dbDriver).ManyDeclare(queryTextConstant, argInterface, returnInterface, query), + ":execrows" => ((IExecRows)dbDriver).ExecRowsDeclare(queryTextConstant, argInterface, query), + ":execlastid" => ((IExecLastId)dbDriver).ExecLastIdDeclare(queryTextConstant, argInterface, query), + ":copyfrom" => ((ICopyFrom)dbDriver).CopyFromDeclare(queryTextConstant, argInterface, query), + _ => throw new NotSupportedException($"{query.Cmd} is not supported") + }; + } + catch (Exception e) + { + throw new SystemException($"Failed to add method declaration for query: {query.Name}", e); + } } } \ No newline at end of file