I'm getting a strange error
when flushing the session after the following sequence of
creations:
def
test_nodes(self):
algs = [Algorithm(name='a'+str(num)) for num in range(0,7)]
1) params = [Parameter(name='p'+str(num)) for num in range(0,20)]
for a in algs:
self.db.session.save(a)
for p in params:
self.db.session.save(p)
Edge(from_node=params[0],to_node=algs[0])
Edge(from_node=params[1],to_node=algs[0])
Edge(from_node=params[2],to_node=algs[0])
Edge(from_node=params[1],to_node=algs[1])
Edge(from_node=params[2],to_node=algs[1])
Edge(from_node=params[3],to_node=algs[1])
Edge(from_node=params[4],to_node=algs[1])
Edge(from_node=params[4],to_node=algs[2])
Edge(from_node=params[5],to_node=algs[2])
Edge(from_node=params[6],to_node=algs[2])
Edge(from_node=algs[0],to_node=params[7])
Edge(from_node=algs[0],to_node=params[8])
Edge(from_node=algs[1],to_node=params[9])
Edge(from_node=algs[1],to_node=params[10])
Edge(from_node=algs[2],to_node=params[11])
Edge(from_node=algs[2],to_node=params[12])
Edge(from_node=algs[2],to_node=params[13])
Edge(from_node=params[7],to_node=algs[3])
Edge(from_node=params[8],to_node=algs[3])
Edge(from_node=params[9],to_node=algs[3])
Edge(from_node=params[10],to_node=algs[3])
Edge(from_node=params[4],to_node=algs[4])
Edge(from_node=params[10],to_node=algs[4])
Edge(from_node=params[11],to_node=algs[4])
Edge(from_node=params[12],to_node=algs[4])
Edge(from_node=params[13],to_node=algs[4])
Edge(from_node=algs[3],to_node=params[14])
Edge(from_node=algs[3],to_node=params[15])
Edge(from_node=algs[4],to_node=params[16])
Edge(from_node=params[7],to_node=algs[5])
Edge(from_node=params[14],to_node=algs[5])
Edge(from_node=params[15],to_node=algs[5])
Edge(from_node=params[14],to_node=algs[6])
Edge(from_node=params[15],to_node=algs[6])
Edge(from_node=params[16],to_node=algs[6])
Edge(from_node=params[13],to_node=algs[6])
Edge(from_node=algs[5],to_node=params[17])
Edge(from_node=algs[6],to_node=params[18])
Edge(from_node=algs[6],to_node=params[19])
self.db.session.flush()
a = self.db.session.query(Algorithm).get_by_name('a4')
assert set([p.name for p in a.inputs]) \
== set(['p10','p4','p11','p12','p13'])
algs = [Algorithm(name='a'+str(num)) for num in range(0,7)]
1) params = [Parameter(name='p'+str(num)) for num in range(0,20)]
for a in algs:
self.db.session.save(a)
for p in params:
self.db.session.save(p)
Edge(from_node=params[0],to_node=algs[0])
Edge(from_node=params[1],to_node=algs[0])
Edge(from_node=params[2],to_node=algs[0])
Edge(from_node=params[1],to_node=algs[1])
Edge(from_node=params[2],to_node=algs[1])
Edge(from_node=params[3],to_node=algs[1])
Edge(from_node=params[4],to_node=algs[1])
Edge(from_node=params[4],to_node=algs[2])
Edge(from_node=params[5],to_node=algs[2])
Edge(from_node=params[6],to_node=algs[2])
Edge(from_node=algs[0],to_node=params[7])
Edge(from_node=algs[0],to_node=params[8])
Edge(from_node=algs[1],to_node=params[9])
Edge(from_node=algs[1],to_node=params[10])
Edge(from_node=algs[2],to_node=params[11])
Edge(from_node=algs[2],to_node=params[12])
Edge(from_node=algs[2],to_node=params[13])
Edge(from_node=params[7],to_node=algs[3])
Edge(from_node=params[8],to_node=algs[3])
Edge(from_node=params[9],to_node=algs[3])
Edge(from_node=params[10],to_node=algs[3])
Edge(from_node=params[4],to_node=algs[4])
Edge(from_node=params[10],to_node=algs[4])
Edge(from_node=params[11],to_node=algs[4])
Edge(from_node=params[12],to_node=algs[4])
Edge(from_node=params[13],to_node=algs[4])
Edge(from_node=algs[3],to_node=params[14])
Edge(from_node=algs[3],to_node=params[15])
Edge(from_node=algs[4],to_node=params[16])
Edge(from_node=params[7],to_node=algs[5])
Edge(from_node=params[14],to_node=algs[5])
Edge(from_node=params[15],to_node=algs[5])
Edge(from_node=params[14],to_node=algs[6])
Edge(from_node=params[15],to_node=algs[6])
Edge(from_node=params[16],to_node=algs[6])
Edge(from_node=params[13],to_node=algs[6])
Edge(from_node=algs[5],to_node=params[17])
Edge(from_node=algs[6],to_node=params[18])
Edge(from_node=algs[6],to_node=params[19])
self.db.session.flush()
a = self.db.session.query(Algorithm).get_by_name('a4')
assert set([p.name for p in a.inputs]) \
== set(['p10','p4','p11','p12','p13'])
At some point, it tries to re-insert one of the
Parameter nodes created at 1) above, initially created with
2006-09-26 14:53:59,192 INFO
sqlalchemy.engine.base.ComposedSQLEngine.0x190cc66c
INSERT INTO nodes (project_id, type, name, description, comments, start_version
_id, end_version_id, sub_project_id, sub_project_version_id, value, previous_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2006-09-26 14:53:59,193 INFO sqlalchemy.engine.base.ComposedSQLEngine.0x190cc66c
[None, 2, 'p14', None, None, None, None, None, None, None, None]
INSERT INTO nodes (project_id, type, name, description, comments, start_version
_id, end_version_id, sub_project_id, sub_project_version_id, value, previous_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2006-09-26 14:53:59,193 INFO sqlalchemy.engine.base.ComposedSQLEngine.0x190cc66c
[None, 2, 'p14', None, None, None, None, None, None, None, None]
with the following (now is inserting over the existing primary key, causing
an integrity error)
SQLError: (IntegrityError) PRIMARY KEY must be unique 'INSERT INTO nodes
(projec
t_id, id, type, name, description, comments, start_version_id, end_version_id, s
ub_project_id, sub_project_version_id, value, previous_id) VALUES (?, ?, ?, ?, ?
, ?, ?, ?, ?, ?, ?, ?)' [None, 2, 2, 'p14', None, None, None, None, None, None,
None, None]
t_id, id, type, name, description, comments, start_version_id, end_version_id, s
ub_project_id, sub_project_version_id, value, previous_id) VALUES (?, ?, ?, ?, ?
, ?, ?, ?, ?, ?, ?, ?)' [None, 2, 2, 'p14', None, None, None, None, None, None,
None, None]
Attached are two files that are a test case. You need nose to run the
test: put them in the same directory and run 'nosetests' (Or manually run
the setUp, test_nodes, and tearDown methods of test_db.py:TestRelateDB).
On re-running the test case before sending, I found that it has several
different possible results. I included four output files from recent runs to
demonstrate. All of these runs are with the attached code.
Any help would be much appreciated,
-Dave H
test.tar.gz
Description: test.tar.gz
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users