Skip to content

Commit

Permalink
only write ',' when an element was written
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed Apr 17, 2024
1 parent 912f81e commit e65d9bb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/EdgeDB.Net.QueryBuilder/Grammar/Terms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ public static QueryWriter Shape<T>(this QueryWriter writer, string name, T[] ele
for (var i = 0; i < elements.Length; i++)
{
func(writer, elements[i]);
var iLocal = i;
var isEmpty = writer.AppendIsEmpty(Value.Of(writer => func(writer, elements[iLocal])));
if (i + 1 < elements.Length)
if (!isEmpty && i + 1 < elements.Length)
writer.Append(", ");
}
Expand All @@ -86,9 +87,11 @@ public static QueryWriter Shape<T>(this QueryWriter writer, string name, params
for (var i = 0; i < elements.Length; i++)
{
elements[i].Write(writer);
var iLocal = i;
if (i + 1 != elements.Length)
var isEmpty = writer.AppendIsEmpty(Value.Of(writer => elements[iLocal].Write(writer)));
if (!isEmpty && i + 1 != elements.Length)
writer.Append(", ");
}
Expand Down

0 comments on commit e65d9bb

Please sign in to comment.