Giter Club home page Giter Club logo

Comments (5)

gusmith avatar gusmith commented on May 22, 2024 1

The issue is actually linked to the user role you are using @Olegt0rr (I'm facing the same one with the readWrite role).
Under the hood, the save method uses the collection update_one with the attribute by_pass_document_validation set to True (https://github.com/art049/odmantic/blob/master/odmantic/engine.py#L319).

From mongodb's documentation about bypassing the document validation:

the authenticated user must have bypassDocumentValidation action. The built-in roles dbAdmin and restore provide this action.

@art049 any reason to bypass the document validation?

from odmantic.

art049 avatar art049 commented on May 22, 2024

Do you have a bit more details about your connection string ?

I tried to reproduce in a test but it seemed to work.

async def test_custom_motor_database(motor_client):
    engine = AIOEngine(motor_client, database="forest")

    class Tree(Model):
        f: str

    await engine.save(Tree(f="aaa"))

from odmantic.

Olegt0rr avatar Olegt0rr commented on May 22, 2024

@art049,

I use cloud-hosted Replica set with mongodb.com (on AWS servers).

My connection string looks like:
mongodb+srv://{login}:{password}@{host}.mongodb.net/test?retryWrites=true&w=majority

Could you try to reproduce the issue with readWrite role? (revoke other permissions)

from odmantic.

Olegt0rr avatar Olegt0rr commented on May 22, 2024

@gusmith, thanks for an answer!

In my opinion, bypass_document_validation parameter is redundant in model's .save() method.
For those not using schema validation, it adds the need for an additional role, although it is not useful at all.
And for those who use validation in collections, it destroys their expectations for validation (disabling of validation is not clear in this case).

@art049,
what do you think about removing this parameter or making it's optional, as a passed parameter?

from odmantic.

art049 avatar art049 commented on May 22, 2024

Well you're right @gusmith, it's useless right now actually. We can totally remove it.
@Olegt0rr i'm not sure people are using really using it actually. We can still add it but it will be necessary to add it in the doc as well.

from odmantic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.