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

Query-to-SQL translation issue with multiple AND clauses and 'negated any' #3614

Open
Healios opened this issue Dec 29, 2024 · 2 comments
Open

Comments

@Healios
Copy link

Healios commented Dec 29, 2024

Hello

I'm getting some funny query results in one of my projects. Specifically, I have the following query, which uses a "negated any" as a workaround since MartenDb doesn’t support "All". While the "negated any" works fine on its own or with certain clauses, MartenDb appears unable to correctly translate the Where clause in the example below:

public IExecutable<Event> WebStyleSearchAndParticipantIncorrect([Service] IDocumentSession session, CancellationToken cancellationToken) =>
    session.Query<Event>()
        .Where(pEvent => pEvent.WebStyleSearch("Marketing OR Sustainability") && !pEvent.Participants.Any(participant => !participant.Name.StartsWith("D")))
        .AsExecutable();

I've created a minimal reproduction project that you can review here: https://github.com/Healios/martendb-incorrect-sql-generation. The README should appropriately explain how to run the project, seed the database, and test the different scenarios.

@jeremydmiller
Copy link
Member

jeremydmiller commented Dec 29, 2024

@Healios,

Hey, a pull request with a failing test would have been a much better way to send us the reproduction steps if you ever need to do this again. Happy with a good repro regardless, but the first thing I'll do is adapt your repository as a test inside the Marten codebase itself.

Marten does support the LINQ All() in some cases. I know because that was a massive PITA to support.

@Healios
Copy link
Author

Healios commented Dec 30, 2024

@jeremydmiller

Noted. I’ve looked through the project and can put together a pull request if that would help.

It seems I just ran into one of the exceptions with All().

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

No branches or pull requests

2 participants