Let __init__ of your model get access to all given properties#160
Let __init__ of your model get access to all given properties#160ticosax wants to merge 1 commit intobiosustain:masterfrom
Conversation
In some scenario your model might define some default values based on properties given at creation time. This is only possible if __init__ receives all properties at once.
|
Unfortunately, this will not always work as the constructor of a model sometimes has unexpected behavior. |
|
The current implementation is slower due to iteration of every properties and not very pythonic. If there is an expected way of constructing an instance of a class is by passing all the argument to the constructor. Initializing an instance and then calling |
|
I agree that it is not ideal, but there are legitimate issues with the other approach that led to this implementation. For one, SQLAlchemy imposes no restrictions on the constructor of a class. An acceptable approach could be calling the https://docs.sqlalchemy.org/en/latest/orm/constructors.html Given that this code is only used in a write operation, I don't see speed as the primary concern. |
|
Even if they claim they impose anything on It means this is legit to expect SQLAlchemy bypasses |
In some scenario your model might define some default values based on properties given at creation time.
This is only possible if
__init__receives all properties at once.