Skip to content

Commit

Permalink
column_type_codes 可能越界,加下判断
Browse files Browse the repository at this point in the history
  • Loading branch information
feiazifeiazi committed Oct 14, 2024
1 parent ccaa469 commit 391d9d1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sql/engines/pgsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def query(
else:
rows = cursor.fetchall()
fields = cursor.description

column_type_codes = [i[1] for i in fields] if fields else []
# 定义 JSON 和 JSONB 的 type_code,# 114 是 json,3802 是 jsonb
JSON_TYPE_CODE = 114
Expand All @@ -214,7 +213,7 @@ def query(
for row in rows:
new_row = []
for idx, col_value in enumerate(row):
column_type_code = column_type_codes[idx]
column_type_code = column_type_codes[idx] if idx < len(column_type_codes) else None
# 只在列类型为 json 或 jsonb 时转换
if column_type_code in [JSON_TYPE_CODE, JSONB_TYPE_CODE]:
if isinstance(col_value, (dict, list)):
Expand Down

0 comments on commit 391d9d1

Please sign in to comment.