Skip to content

Commit

Permalink
Merge pull request #14 from sommelon/master
Browse files Browse the repository at this point in the history
fix #13: Fixed Migrator converting NULL values to a string 'None'
  • Loading branch information
tcitry authored Apr 15, 2021
2 parents 58088ed + 16991fb commit 14528d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mirage/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ def executor(self, apps=None, schema_editor=None, offset=0, total=None, limit=10
execute_sql = ''
for value in value_list:
if method in ['encrypt', 'decrypt']:
execute_sql += f"update {db_table} set {self.field}='{value[1]}' where id='{value[0]}';"
if value[1] is None:
execute_sql += f"update {db_table} set {self.field}=NULL where id='{value[0]}';"
else:
execute_sql += f"update {db_table} set {self.field}='{value[1]}' where id='{value[0]}';"
elif method in ['copy_to', 'encrypt_to', 'decrypt_to']:
execute_sql += f"update {db_table} set {self.tofield}='{value[1]}' where id='{value[0]}';"
if value[1] is None:
execute_sql += f"update {db_table} set {self.tofield}=NULL where id='{value[0]}';"
else:
execute_sql += f"update {db_table} set {self.tofield}='{value[1]}' where id='{value[0]}';"
cursor.execute(execute_sql)
if value_list:
if limit == -1:
Expand Down

0 comments on commit 14528d5

Please sign in to comment.