Comments (5)
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.
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.
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.
@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.
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)
- Using deprecated `pydantic.datetime_parse:parse_datetime` in Pydantic HOT 1
- Can't start dev container: multi-python is deprecated
- Optional EmbeddedModel not working HOT 3
- Just started following tutorial in https://art049.github.io/odmantic/ and an error HOT 3
- Any specific reason to not support model inheritance?
- `Optional[str]` triggers `int_parsing` instead of string parsing when used for `odmantic.Model` HOT 4
- Multiple sorting criteria HOT 1
- Mypy issues for odmantic 1.0.0 HOT 2
- Trying to use db_engine.configure_database([User]) HOT 1
- Support Inheritance
- regex is removed in pydantic 2.x this causes the Field class to throw an exception if its used. HOT 1
- Support for Optional types as X | None HOT 1
- Embedded models have to be defined before any normal models that reference them HOT 4
- Question: how to mock/write propper unittests HOT 2
- when a model has many optional field, it will raise unwanted validation type error HOT 4
- Odmantic Does Not Add Pydantic Computed Fields to MongoDB HOT 1
- Aggregation support via the find method HOT 1
- Datetime not updating and not updating frequently
- Injected Context for Model Class not picked up
- Unexpected @field_validator behaviour
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odmantic.