From 6171e12f9fb2603f2c9cb076f85808c257273453 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sat, 19 Jun 2021 02:10:49 -0400 Subject: [PATCH] orm: don't panic for a psql query with no results. (#10511) --- vlib/v/gen/c/sql.v | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vlib/v/gen/c/sql.v b/vlib/v/gen/c/sql.v index bc168cdb25..31879a32b5 100644 --- a/vlib/v/gen/c/sql.v +++ b/vlib/v/gen/c/sql.v @@ -994,6 +994,7 @@ fn (mut g Gen) psql_select_expr(node ast.SqlExpr, sub bool, line string, typ Sql g.writeln('};') } fields := g.new_tmp_var() + g.writeln('if (${rows}.len > 0) {') g.writeln('Array_string $fields = (*(pg__Row*) array_get($rows, $tmp_i)).vals;') fld := g.new_tmp_var() g.writeln('string $fld;') @@ -1050,6 +1051,7 @@ fn (mut g Gen) psql_select_expr(node ast.SqlExpr, sub bool, line string, typ Sql g.writeln('\t array_push((array*)&${tmp}_array, _MOV(($elem_type_str[]) { $tmp }));\n') g.writeln('}') } + g.writeln('}') g.writeln('string_free(&$g.sql_stmt_name);') if node.is_array { g.writeln('$cur_line ${tmp}_array; ')