Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlBuilder: GroupBy / Having randomly added when creating query #573

Open
MikeKry opened this issue Jun 28, 2024 · 0 comments
Open

SqlBuilder: GroupBy / Having randomly added when creating query #573

MikeKry opened this issue Jun 28, 2024 · 0 comments

Comments

@MikeKry
Copy link

MikeKry commented Jun 28, 2024

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.

image

I do not understand why it happens, as it does happens unpredictably.

Here is full code:
image

It seems that it happens always when sqlBuilder object is viewed in debugger

Fix could be using Count instead of null comparison here

sb.Append(" GROUP BY ");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant