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

Search within collections generate separate subqueries for each field, rather than merging all searches within the collection together. #466

Open
ascott18 opened this issue Oct 2, 2024 · 0 comments
Labels

Comments

@ascott18
Copy link
Collaborator

ascott18 commented Oct 2, 2024

Actual:

SELECT COUNT(*)
FROM [UploadedFiles] AS [u]
WHERE (LOWER([u].[OriginalPath]) LIKE @__Value_1_contains ESCAPE N'\' OR EXISTS (
    SELECT 1
    FROM [ProcessingEvents] AS [p]
    LEFT JOIN [Foos] AS [r] ON [p].[FooId] = [r].[Id]
    WHERE [u].[Id] = [p].[ProcessedFileId] AND [r].[Name] IS NOT NULL AND LOWER([r].[Name]) LIKE @__Value_2_contains ESCAPE N'\') OR EXISTS (
    SELECT 1
    FROM [ProcessingEvents] AS [p0]
    LEFT JOIN [Foos] AS [r0] ON [p0].[FooId] = [r0].[Id]
    WHERE [u].[Id] = [p0].[ProcessedFileId] AND [r0].[Code] IS NOT NULL AND LOWER([r0].[Code]) LIKE @__Value_3_contains ESCAPE N'\') OR EXISTS (
    SELECT 1
    FROM [ProcessingEvents] AS [p1]
    LEFT JOIN [Foos] AS [r1] ON [p1].[FooId] = [r1].[Id]
    WHERE [u].[Id] = [p1].[ProcessedFileId] AND [r1].[Description] IS NOT NULL AND LOWER([r1].[Description]) LIKE @__Value_4_contains ESCAPE N'\'))

Desired:

SELECT COUNT(*)
FROM [UploadedFiles] AS [u]
WHERE (LOWER([u].[OriginalPath]) LIKE @__Value_1_contains ESCAPE N'\' OR EXISTS (
    SELECT 1
    FROM [ProcessingEvents] AS [p]
    LEFT JOIN [Foos] AS [r] ON [p].[FooId] = [r].[Id]
    WHERE [u].[Id] = [p].[ProcessedFileId] AND (
	([r].[Name] IS NOT NULL AND LOWER([r].[Name]) LIKE @__Value_2_contains ESCAPE N'\') OR
	([r].[Code] IS NOT NULL AND LOWER([r].[Code]) LIKE @__Value_2_contains ESCAPE N'\') OR
	([r].[Description] IS NOT NULL AND LOWER([r].[Description]) LIKE @__Value_2_contains ESCAPE N'\')
	))
@ascott18 ascott18 added the bug label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant