-
-
Notifications
You must be signed in to change notification settings - Fork 200
Description
I have run into some unexpected behavior of SqlBuilder.
When I create sql builder from scratch, sometimes it returns empty group by / having clauses from ToSqlString() method.
"SELECT [LocalizedContentItemIndex_a1].[LocalizationSet] FROM [LocalizedContentItemIndex] AS [b] WHERE [b].[Culture] = 'cs-cz' AND [b].[Published] = 1 AND [b].[Published] = 1 AND [LocalizedContentItemIndex_a1].[LocalizationSet] = [b].[LocalizationSet] GROUP BY HAVING "
It can be fixed by calling ClearGroupBy(), which sets internal _group and _having property to null instead of empty array.
I do not understand why it happens, as it does happens unpredictably.
It seems that it happens always when sqlBuilder object is viewed in debugger
Fix could be using Count instead of null comparison here
yessql/src/YesSql.Core/Sql/SqlBuilder.cs
Line 383 in 01fea28
| sb.Append(" GROUP BY "); |

