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

Panache MongoDB doesn't support collation in count #27063

Closed
diogocarleto opened this issue Aug 1, 2022 · 2 comments · Fixed by #27062
Closed

Panache MongoDB doesn't support collation in count #27063

diogocarleto opened this issue Aug 1, 2022 · 2 comments · Fixed by #27062
Labels
Milestone

Comments

@diogocarleto
Copy link
Contributor

Describe the bug

Panache MongoDB doesn't support collation for count.
Taking a look in the io.quarkus.mongodb.panache.common.runtime.CommonPanacheQueryImpl and io.quarkus.mongodb.panache.common.reactive.runtime.CommonReactivePanacheQueryImpl we can see the method count doesn't support collation.

Native queries and panache queries already support this, we can confirm in this PR from @loicmathieu already merged.

I implemented the fix, basically I changed a small piece in CommonReactivePanacheQueryImpl and CommonPanacheQueryImpl:

public Uni<Long> count() {
        if (count == null) {
            CountOptions countOptions = new CountOptions();
            if (collation != null) {
                countOptions.collation(collation);
            }

            count = mongoQuery == null
                    ? collection.countDocuments()
                    : collection.countDocuments(mongoQuery, countOptions);
        }
        return count;
    }
public long count() {
        if (count == null) {
            Bson query = getQuery();
            CountOptions countOptions = new CountOptions();
            if (collation != null) {
                countOptions.collation(collation);
            }

            count = clientSession == null
                    ? collection.countDocuments(query, countOptions)
                    : collection.countDocuments(clientSession, query, countOptions);
        }
        return count;
    }

Here is the PR, let me know if I need to change something.

Best regards.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@diogocarleto diogocarleto added the kind/bug Something isn't working label Aug 1, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 1, 2022

/cc @FroMage, @evanchooly, @loicmathieu

@loicmathieu
Copy link
Contributor

I agree this is a bug and I also agree with tge fix.

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

Successfully merging a pull request may close this issue.

2 participants