Skip to content

Commit 16991fb

Browse files
committed
fix luojilab#13: Fixed Migrator converting NULL values to a string 'None'
1 parent 58088ed commit 16991fb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mirage/tools.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ def executor(self, apps=None, schema_editor=None, offset=0, total=None, limit=10
7272
execute_sql = ''
7373
for value in value_list:
7474
if method in ['encrypt', 'decrypt']:
75-
execute_sql += f"update {db_table} set {self.field}='{value[1]}' where id='{value[0]}';"
75+
if value[1] is None:
76+
execute_sql += f"update {db_table} set {self.field}=NULL where id='{value[0]}';"
77+
else:
78+
execute_sql += f"update {db_table} set {self.field}='{value[1]}' where id='{value[0]}';"
7679
elif method in ['copy_to', 'encrypt_to', 'decrypt_to']:
77-
execute_sql += f"update {db_table} set {self.tofield}='{value[1]}' where id='{value[0]}';"
80+
if value[1] is None:
81+
execute_sql += f"update {db_table} set {self.tofield}=NULL where id='{value[0]}';"
82+
else:
83+
execute_sql += f"update {db_table} set {self.tofield}='{value[1]}' where id='{value[0]}';"
7884
cursor.execute(execute_sql)
7985
if value_list:
8086
if limit == -1:

0 commit comments

Comments
 (0)