Skip to content

Commit

Permalink
Merge pull request #2 from floatliang/master
Browse files Browse the repository at this point in the history
parser of update switch to parse func
  • Loading branch information
DeeeFOX authored Dec 11, 2019
2 parents 0510294 + 127cfcc commit 178556a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/porm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,12 @@ def update(self, t: _transaction = None, **filters):

if not filters:
filters = self.pk_fields
f = []
sql_obj = self._update_sql
sql = sql_obj.sql
param = sql_obj.param
for key, val in filters.items():
f.append(u'{key}=%(f_{key})s'.format(key=key))
param[u'f_' + key] = val
sql = sql.format(filter=' AND '.join(f))
parsed = parse(**filters)
param.update(parsed['param'])
sql = sql.format(filter=parsed['filter'])
mydb = MyDBApi(config=self._get_db_conf(), t=t)
return mydb.insert_one(sql, param)

Expand Down

0 comments on commit 178556a

Please sign in to comment.