Skip to content

Commit

Permalink
只在列类型为 json 或 jsonb 时转换
Browse files Browse the repository at this point in the history
  • Loading branch information
feiazifeiazi committed Oct 11, 2024
1 parent 7c8b3a7 commit a0d2ce4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/engines/pgsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ def query(
for idx, col_value in enumerate(row):
column_type_code = column_type_codes[idx]
# 只在列类型为 json 或 jsonb 时转换
if column_type_code in [JSON_TYPE_CODE, JSONB_TYPE_CODE]:
if column_type_code in [JSON_TYPE_CODE, JSONB_TYPE_CODE]:
if isinstance(col_value, (dict, list)):
new_row.append(json.dumps(col_value)) # 转为 JSON 字符串
else:
new_row.append(col_value)
else:
new_row.append(col_value)
converted_rows.append(tuple(new_row))

result_set.column_list = [i[0] for i in fields] if fields else []
result_set.rows = converted_rows
result_set.affected_rows = effect_row
Expand Down

0 comments on commit a0d2ce4

Please sign in to comment.