--- a/hooks/syncschema.py Thu Mar 18 17:31:22 2010 +0100
+++ b/hooks/syncschema.py Thu Mar 18 17:39:17 2010 +0100
@@ -190,7 +190,7 @@
def prepare_constraints(self, rdef):
# if constraints is already a list, reuse it (we're updating multiple
- # constraints of the same rdef in the same transactions
+ # constraints of the same rdef in the same transactions)
if not isinstance(rdef.constraints, list):
rdef.constraints = list(rdef.constraints)
self.constraints = rdef.constraints
@@ -673,9 +673,8 @@
return
rdef = self.session.vreg.schema.schema_by_eid(rdef.eid)
self.prepare_constraints(rdef)
- subjtype, rtype, objtype = rdef.as_triple()
cstrtype = self.entity.type
- self.cstr = rtype.rdef(subjtype, objtype).constraint_by_type(cstrtype)
+ self.cstr = rdef.constraint_by_type(cstrtype)
self.newcstr = CONSTRAINTS[cstrtype].deserialize(self.entity.value)
self.newcstr.eid = self.entity.eid
--- a/rset.py Thu Mar 18 17:31:22 2010 +0100
+++ b/rset.py Thu Mar 18 17:39:17 2010 +0100
@@ -287,12 +287,14 @@
newselect = stmts.Select()
newselect.limit = limit
newselect.offset = offset
- aliases = [nodes.VariableRef(newselect.get_variable(vref.name, i))
- for i, vref in enumerate(rqlst.selection)]
+ aliases = [nodes.VariableRef(newselect.get_variable(chr(65+i), i))
+ for i in xrange(len(rqlst.children[0].selection))]
+ for vref in aliases:
+ newselect.append_selected(nodes.VariableRef(vref.variable))
newselect.set_with([nodes.SubQuery(aliases, rqlst)], check=False)
newunion = stmts.Union()
newunion.append(newselect)
- rql = rqlst.as_string(kwargs=self.args)
+ rql = newunion.as_string(kwargs=self.args)
rqlst.parent = None
return rql
--- a/schemas/_regproc_bss.postgres.sql Thu Mar 18 17:31:22 2010 +0100
+++ b/schemas/_regproc_bss.postgres.sql Thu Mar 18 17:39:17 2010 +0100
@@ -32,7 +32,7 @@
'SELECT X.cw_%s FROM cw_%s as X WHERE X.cw_eid=$1' % (args[2], args[1]),
['bigint'])
SD[pkey] = plan
- return plpy.execute(plan, [args[0]])[0]
+ return plpy.execute(plan, [args[0]])[0]['cw_' + args[2]]
$$ LANGUAGE plpythonu
/* WITH(ISCACHABLE) XXX does postgres handle caching of large data nicely */
;;
--- a/server/migractions.py Thu Mar 18 17:31:22 2010 +0100
+++ b/server/migractions.py Thu Mar 18 17:39:17 2010 +0100
@@ -500,11 +500,13 @@
self._synchronized.add((subjtype, rschema, objtype))
if rschema.symmetric:
self._synchronized.add((objtype, rschema, subjtype))
+ rdef = rschema.rdef(subjtype, objtype)
+ if rdef.infered:
+ return # don't try to synchronize infered relation defs
+ repordef = reporschema.rdef(subjtype, objtype)
confirm = self.verbosity >= 2
if syncprops:
# properties
- rdef = rschema.rdef(subjtype, objtype)
- repordef = reporschema.rdef(subjtype, objtype)
self.rqlexecall(ss.updaterdef2rql(rdef, repordef.eid),
ask_confirm=confirm)
# constraints
@@ -523,15 +525,13 @@
self.rqlexec('DELETE X constrained_by C WHERE C eid %(x)s',
{'x': cstr.eid}, 'x',
ask_confirm=confirm)
- self.rqlexec('DELETE CWConstraint C WHERE C eid %(x)s',
- {'x': cstr.eid}, 'x',
- ask_confirm=confirm)
else:
newconstraints.remove(newcstr)
- values = {'x': cstr.eid,
- 'v': unicode(newcstr.serialize())}
- self.rqlexec('SET X value %(v)s WHERE X eid %(x)s',
- values, 'x', ask_confirm=confirm)
+ value = unicode(newcstr.serialize())
+ if value != unicode(cstr.serialize()):
+ self.rqlexec('SET X value %(v)s WHERE X eid %(x)s',
+ {'x': cstr.eid, 'v': value}, 'x',
+ ask_confirm=confirm)
# 2. add new constraints
cstrtype_map = self.cstrtype_mapping()
self.rqlexecall(ss.constraints2rql(cstrtype_map, newconstraints,
--- a/server/repository.py Thu Mar 18 17:31:22 2010 +0100
+++ b/server/repository.py Thu Mar 18 17:39:17 2010 +0100
@@ -335,7 +335,8 @@
self.info('waiting thread %s...', thread.name)
thread.join()
self.info('thread %s finished', thread.name)
- self.hm.call_hooks('server_shutdown', repo=self)
+ if not (self.config.creating or self.config.repairing):
+ self.hm.call_hooks('server_shutdown', repo=self)
self.close_sessions()
while not self._available_pools.empty():
pool = self._available_pools.get_nowait()
--- a/test/unittest_rset.py Thu Mar 18 17:31:22 2010 +0100
+++ b/test/unittest_rset.py Thu Mar 18 17:39:17 2010 +0100
@@ -371,6 +371,18 @@
rset = self.execute(u'Any X WHERE X has_text %(text)s', {'text' : 'foo'})
self.assertEquals(rset.searched_text(), 'foo')
+ def test_union_limited_rql(self):
+ rset = self.execute('(Any X,N WHERE X is Bookmark, X title N)'
+ ' UNION '
+ '(Any X,N WHERE X is CWGroup, X name N)')
+ rset.limit(2, 10, inplace=True)
+ self.assertEquals(rset.limited_rql(),
+ 'Any A,B LIMIT 2 OFFSET 10 '
+ 'WITH A,B BEING ('
+ '(Any X,N WHERE X is Bookmark, X title N) '
+ 'UNION '
+ '(Any X,N WHERE X is CWGroup, X name N)'
+ ')')
if __name__ == '__main__':
unittest_main()