Replies: 7 comments 17 replies
-
Iterating relationsOrmar uses same method to iterate nested models and avoid going into infinite recursion loop. The same one is use in Meaning in schema like this: A # <= this A wont be saved/loaded as root node is A, but if X have a fk column to A it will be saved
/
B - C - D - X - Z
/
A - C - U - X - O - K
\
U # <= this U won't be saved/loaded as U was already between C and X in this branch, but fk value in O will be saved Saving nested modelsBy default only the main models are saved, but you can save deeply related models in at least two ways -> depending on your data structure. One way is That's why you have signals (pre/post save/update/delete), where you get sender class (model), current instance etc. So for example you can define signal receiver function so that D is always saved in pre_save/pre_update hook each time the main model is saved/updated and rest is managed by Fetching nested modelsIf you query the db with Oracle and Couchbase supportUnfortunately |
Beta Was this translation helpful? Give feedback.
-
I feel some unclearness for the requirement ormar has for one2many, one2one relation . Maybe i'm not looking in the right place, i.e:
I tried to find an example of saved_related /select_all/ on documentation , I tried building quite nested objects but got messed up
got confuse with the way ormar creates the object relation, Code:
referring to example of nested object, following ur explanation for limitation of "repeatable " objects. customer can have one address (one2one), Json can look like:
Do you see an issue describing this module with ormar? |
Beta Was this translation helpful? Give feedback.
-
@collerek - thanks much for your detailed reply , ok now I understand why it required first to have the Parent object save before preforming save_all, my Q - if there were more child below courses , is that means we need do save each dependencies as well?
In case yes and there's no other way to simplify the process ... as far as i search it seem this functionality required by many, @scd75 provide some alternate declarative_base() (sqlalchamy orm) : I tried to implement it but seems it provide partials solution - so maybe It been more than a month that I search for " ORM package for purpose i explain, I'd like to share with you some suggestion if i may , I wonder if it can combine to single solution or maybe implement in similar fashion ,
pyantic to sqlalchemy
I think it would be really awesome if the tool will do the creation of orman model automatically again, thanks much for your assistant and explanation . |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@collerek , Trying to post getting error for "DatabaseBackend is not running":
Main:
Router:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @collerek , seems select_all() would be better way for my purpose as at current im interested to
those Pk/FK being added/generated automatically , |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Interested replacing sqlalachamy and ormar looks promising:)
need your kind help understanding if ormar is my best alternative :
1.Most important - support a complex/nested objects ?
case yes , is there any limitation for nested level depth or types.
The complexity of data i have can be really challenge ,
So for post request with a nested object as input,
can ormar read the nested json i.e ,and populated to the relevant tables (by predefine models)?
i.e :
Beta Was this translation helpful? Give feedback.
All reactions