equal
deleted
inserted
replaced
212 """return a dictionary to use as extra argument to cursor.execute |
212 """return a dictionary to use as extra argument to cursor.execute |
213 to insert/update an entity into a SQL database |
213 to insert/update an entity into a SQL database |
214 """ |
214 """ |
215 attrs = {} |
215 attrs = {} |
216 eschema = entity.e_schema |
216 eschema = entity.e_schema |
217 for attr, value in entity.items(): |
217 for attr in entity.edited_attributes: |
|
218 value = entity[attr] |
218 rschema = eschema.subjrels[attr] |
219 rschema = eschema.subjrels[attr] |
219 if rschema.final: |
220 if rschema.final: |
220 atype = str(entity.e_schema.destination(attr)) |
221 atype = str(entity.e_schema.destination(attr)) |
221 if atype == 'Boolean': |
222 if atype == 'Boolean': |
222 value = self.dbhelper.boolean_value(value) |
223 value = self.dbhelper.boolean_value(value) |
234 elif atype == 'Date' and isinstance(value, datetime): |
235 elif atype == 'Date' and isinstance(value, datetime): |
235 value = todate(value) |
236 value = todate(value) |
236 elif isinstance(value, Binary): |
237 elif isinstance(value, Binary): |
237 value = self._binary(value.getvalue()) |
238 value = self._binary(value.getvalue()) |
238 attrs[SQL_PREFIX+str(attr)] = value |
239 attrs[SQL_PREFIX+str(attr)] = value |
|
240 attrs[SQL_PREFIX+'eid'] = entity.eid |
239 return attrs |
241 return attrs |
240 |
242 |
241 |
243 |
242 from logging import getLogger |
244 from logging import getLogger |
243 from cubicweb import set_log_methods |
245 from cubicweb import set_log_methods |