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

Method db.collection.distinct is not implemented. #6

Closed
lala7573 opened this issue May 4, 2020 · 11 comments
Closed

Method db.collection.distinct is not implemented. #6

lala7573 opened this issue May 4, 2020 · 11 comments

Comments

@lala7573
Copy link

lala7573 commented May 4, 2020

Hi, I'm using DataGrip with mongodb driver and faced error

Method db.collection.distinct is not implemented.

And found out it's really not implemented.
https://github.com/DataGrip/mongo-jdbc-driver/blob/master/src/main/java/com/dbschema/mongo/nashorn/JMongoCollection.java#L66

Is there any plan to support this? and why doesn't it work?

@kornilova203
Copy link
Contributor

Hello @lala7573,
Soon we will change our methods implementation to mongodb-js/mongosh and most of the methods will be supported. I believe it will happen within 2 weeks.

Though distinct method is a bit tricky but I think I will be able to make it work

@kornilova203
Copy link
Contributor

The problem is that MongoDB did not provide a way to execute shell scripts outside the command-line shell.
But with mongodb-js/mongosh it will be possible. I currently work on Java wrapper for it.

@alexander-alegre
Copy link

Using the latest of DataGrip (2021.1.3) the issue is still present. Any update?

@kornilova203
Copy link
Contributor

Hello @alexander-alegre,
I'll check next week if I can fix this issue

@kornilova203
Copy link
Contributor

Hi all!
Sorry that it took so much time to fix the issue
I've implemented distinct operation, it will be in MongoDB driver soon
mongodb-js/mongosh#1073

But there is a limitation unfortunately: all values should be of one type because Java driver for MongoDB requires you to specify type for value comparison. In my implementation I use type of the first value in a given field.
If there are different types, you'll see an error like Invalid numeric type, found: STRING.
Though you always can filter documents using second parameter in distinct function e.g. db.collection.distinct('color', {type: 'plane'})

@rahulroy9202
Copy link

Using the latest of DataGrip (2021.2.2) MongoDB Driver Version 1.12 the issue is still present. Any update? Thanks

@GilbertOstlethwaite
Copy link

DataGrip 2021.2.4 and the issue is still present

@kornilova203
Copy link
Contributor

It works for me:
image

@rahulroy9202, could you please share a command that you run and an error that you get?

@GilbertOstlethwaite, you need to update driver. Go to data source connection page, choose Drivers and find MongoDB there:

image

@rahulroy9202
Copy link

rahulroy9202 commented Oct 20, 2021

Hi @kornilova203 I have updated to 2021.2.4 since and tried distinct. It works for me now. Thank You

image

@kornilova203
Copy link
Contributor

@rahulroy9202,
Good!
For your information: usually you need to update drivers manually, they are not updated automatically with IDE updates.
It's because new drivers may have new bugs, and we want users to be aware of the fact that driver was changed.

@kornilova203
Copy link
Contributor

Works as expected in driver v1.18.
If you still have any issues, please let me know here
image

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

5 participants