elixir-mongo / mongodb_ecto

MongoDB adapter for Ecto
Apache License 2.0
368 stars 126 forks source link

Do not truncate MongoDB views #167

Closed exAspArk closed 5 years ago

exAspArk commented 5 years ago

Hi!

When I call Mongo.Ecto.truncate/2, it fails with the following error in case if there is a MongoDB View in a database:

(Mongo.Error) Namespace ecto_test.view is a view, not a collection 166

My changes exclude Views from the collection list to avoid trying to truncate them since these are read-only collections. Initially, I wanted to use list_collections/2 but it returns a list of collection names as strings, so it is not possible to filter out Views after that.

MongoDB Views were introduced in version 3.4.

sourcelevel-bot[bot] commented 5 years ago

Hello, @exAspArk! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 322


Totals Coverage Status
Change from base Build 319: 0.4%
Covered Lines: 302
Relevant Lines: 350

💛 - Coveralls
coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 320


Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/mongo_ecto.ex 7 12 58.33%
<!-- Total: 7 12 58.33% -->
Totals Coverage Status
Change from base Build 319: -1.07%
Covered Lines: 297
Relevant Lines: 350

💛 - Coveralls
ankhers commented 5 years ago

Thank you!