server/sources/native.py
changeset 1251 af40e615dc89
parent 1079 452cb76fe07a
child 1263 01152fffd593
--- a/server/sources/native.py	Mon Apr 06 16:11:38 2009 +0200
+++ b/server/sources/native.py	Mon Apr 06 16:18:46 2009 +0200
@@ -1,7 +1,7 @@
 """Adapters for native cubicweb sources.
 
 :organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 """
 __docformat__ = "restructuredtext en"
@@ -18,7 +18,7 @@
 
 from cubicweb import UnknownEid, AuthenticationError, Binary, server
 from cubicweb.server.utils import crypt_password
-from cubicweb.server.sqlutils import SQLAdapterMixIn
+from cubicweb.server.sqlutils import SQL_PREFIX, SQLAdapterMixIn
 from cubicweb.server.rqlannotation import set_qdata
 from cubicweb.server.sources import AbstractSource
 from cubicweb.server.sources.rql2sql import SQLGenerator
@@ -367,19 +367,19 @@
     def add_entity(self, session, entity):
         """add a new entity to the source"""
         attrs = self.preprocess_entity(entity)
-        sql = self.sqlgen.insert(str(entity.e_schema), attrs)
+        sql = self.sqlgen.insert(SQL_PREFIX + str(entity.e_schema), attrs)
         self.doexec(session.pool[self.uri], sql, attrs)
         
     def update_entity(self, session, entity):
         """replace an entity in the source"""
         attrs = self.preprocess_entity(entity)
-        sql = self.sqlgen.update(str(entity.e_schema), attrs, ['eid'])
+        sql = self.sqlgen.update(SQL_PREFIX + str(entity.e_schema), attrs, [SQL_PREFIX + 'eid'])
         self.doexec(session.pool[self.uri], sql, attrs)
 
     def delete_entity(self, session, etype, eid):
         """delete an entity from the source"""
-        attrs = {'eid': eid}
-        sql = self.sqlgen.delete(etype, attrs)
+        attrs = {SQL_PREFIX + 'eid': eid}
+        sql = self.sqlgen.delete(SQL_PREFIX + etype, attrs)
         self.doexec(session.pool[self.uri], sql, attrs)
 
     def add_relation(self, session, subject, rtype, object):
@@ -392,8 +392,10 @@
         """delete a relation from the source"""
         rschema = self.schema.rschema(rtype)
         if rschema.inlined:
-            etype = session.describe(subject)[0]
-            sql = 'UPDATE %s SET %s=NULL WHERE eid=%%(eid)s' % (etype, rtype)
+            table = SQL_PREFIX + session.describe(subject)[0]
+            column = SQL_PREFIX + rtype
+            sql = 'UPDATE %s SET %s=NULL WHERE %seid=%%(eid)s' % (table, column,
+                                                                  SQL_PREFIX)
             attrs = {'eid' : subject}
         else:
             attrs = {'eid_from': subject, 'eid_to': object}