Hello,

I am actually working on my previous post about the OrderedDict and the 
None values and I met new problems and new questions. I didn't found 
answers on the Internet, so here I am !

As explained in the official documentation (or in the following topic : 
https://groups.google.com/forum/#!msg/sqlalchemy/2dVQTvzmi84/8J8lGpLfw4EJ), 
using backref or back_populates on relationship "sets up the 
"synchronization" of the two directions, which consists of an event that 
performs the complimentary set/append operation when an append/set occurs 
on the other side".

Here is the example gived by the topic previously mentionned :

p = Parent('parent1') 
c = Child('child1') 
c.parent = p 
p.children.append(c) 


*p's children will contain c twice.*

In deed, the "c.parent = p" operation results in the "append" on the other 
side, and vice versa.

In my case, I'm working on an existing project which contains a lot of 
classes and the methods are already designed in order to add the objects on 
the two sides. It is so because the program is using Pickle to persist 
everything (my objectiv is to replace it by SQLAlchemy). Of course, I could 
adapt the code but it will be a lot of work and I don't like the idea that 
my structures are automatically synchronized without explicit declarations. 
Furthermore, what will happen if I decide, one day, to stop using 
SQLAlchemy ? My code would be too dependent on the fonctionnalities 
provided by SQLAlchemy.

So, my questions are :

1) Is it feasible to avoid to use backref or back_populates ? Would it be a 
bad idea to work without these fonctionnalities ? Will I face for example 
inconsistent state of the program ?
2) Is it possible to use back_populates and allow SQLAlchemy to detect that 
it should not append something which was already inserted ?

Thank you very much !

Regards,

Sven


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to