def _get_delete_sql(self, emitter: typing.Callable[[], str], session: 'md_session.Session') \
-> typing.Tuple[str, typing.Any]:
"""
Gets the DELETE sql for this row.
"""
if self._session is None:
self._session = session
query = io.StringIO()
query.write("DELETE FROM {} ".format(self.__quoted_name__))
# generate the where clauses
wheres = []
params = {}
for col, value in zip(self.table.primary_key.columns,
md_inspection.get_pk(self, as_tuple=True)):
name = emitter()
params[name] = value
wheres.append("{} = {}".format(col.quoted_fullname, session.bind.emit_param(name)))
query.write("WHERE ({}) ".format(" AND ".join(wheres)))
return query.getvalue(), params
# value loading methods
评论列表
文章目录