Thank you very much Mike!
The behavior I am getting is very strange.
The test case (I posted and then removed by accident) validates the
behavior of "append to list". IOW: position is correct and not None.
105 def test_backref_set(self):
106 self._setup(ordering_list('position'))
107
108 #session = create_session()
109 s1 = Slide('Slide #1')
110 #session.add(s1)
111 #session.flush()
112
113 self.assert_(not s1.bullets)
114 self.assert_(len(s1.bullets) == 0)
115
116 b0 = Bullet('s1/b0')
117 assert b0.position == None
118 #session.add(b0)
119 b0.slide = s1
120 assert b0.position == 0
121
122 #session.flush()
123
124 self.assert_(s1.bullets)
125 self.assert_(len(s1.bullets) == 1)
126 self.assert_(s1.bullets[0] == b0)
127 self.assert_(s1.bullets[0].position == 0)
>> (*) <<
However, a second test I have (combined with history_meta), the first item
remains with position None until a second item is added using 'append()'.
I am 2x checking my test and trying to ping point what's happening so I can
post it here
--- PS
(*) I even tried using backref() on the many-to-one class and still
obtained the correct "append to list" result when using the same test.
Although notice I commented out the "lazy='joined'"
79
80 """
81 mapper(Slide, slides_table, properties={
82 'bullets': relationship(Bullet, lazy='joined',
83 collection_class=test_collection_class,
84 backref='slide',
85 order_by=[bullets_table.c.position])
86 })
87 mapper(Bullet, bullets_table)
88 """
89 mapper(Slide, slides_table)
90 mapper(Bullet, bullets_table, properties={
91 'slide': relationship(Slide, #lazy='joined',
92 backref=backref('bullets',
93
collection_class=test_collection_class,
94 order_by=[bullets_table.c.position])
95 )
96 }
97 )
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.