On Jan 19, 2006, at 8:21 PM, Michael Bayer wrote:
OK, that was a bug where it breaks down a save dependency into a hierarchical graph of smaller dependencies, when you have a circular mapper going...it was forgetting about all the other dependent operations on the original save dependency.   my three current tests for self-referring mappers didnt take this case into account....so your test is working now if you update.

thanks mike; things seem to be working
for my actual work code.

the dependency processing is still pretty
opaque to me, but i did notice that in
topological.py(L79-81) you have:

            if t[0] is t[1]:
                nodes[t[0]].circular = True
                continue

i was trying to understand the implications
of this.

as a test i looked into trying to create
a 2-loop in the code below, but failed
because FKs require the referent to already
exist. the followup question to this is:
do you imagine ever allowing the creation
of such relations via sqlalchemy?

i was still curious as to what would happen
if i manually created the table definitions
and commented out the .create()s - in that
case i got a:

".../mapping/topological.py", line 96, in sort
    raise "Circular dependency detected " + repr(edges) + repr(queue)
Circular dependency detected {Mapper|C2|t2 (idself=1077381996): {Mapper|C1|t1 (idself=1077381964): True}, Mapper|C1|t1 (idself=1077381964): {Mapper|C2|t2 (idself=1077381996): True}}[]

which makes sense, since the cycle won't get
caught by the 't[0] is t[1]' check.

nevertheless, i also wonder if this is something
that you expect to support in the future?

sorry to be bringing up less common use-cases,
but sqlalchemy gives me the hope of leveraging
these features through python.

thanks,
daishi

---
import sqlalchemy as rdb

engine = rdb.create_engine('sqlite://', echo=True)

t1 = rdb.Table(
    't1', engine,
    rdb.Column('id', rdb.Integer, primary_key=True),
    rdb.Column('t2_id', rdb.Integer, rdb.ForeignKey('t2.id')),
    )
t1.create()
class C1(object):
    pass
m1 = rdb.mapper(C1, t1)

t2 = rdb.Table(
    't2', engine,
    rdb.Column('id', rdb.Integer, primary_key=True),
    rdb.Column('t1_id', rdb.Integer, rdb.ForeignKey(t1.c.id)),
    )
t2.create()
class C2(object):
    pass
m2 = rdb.mapper(C2, t2)

m1.add_property('t2', rdb.relation(m2))
m2.add_property('t1', rdb.relation(m1))

a1 = C1()
a2 = C2()
a1.t2 = a2
a2.t1 = a1
rdb.objectstore.commit()



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to