Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG查询时,将字段类型为json,jsonb的数据转为json字符串 #2837

Merged
merged 10 commits into from
Oct 18, 2024

Conversation

feiazifeiazi
Copy link
Contributor

fix #2234

PG查询时,将字段类型为json,jsonb的数据转为json字符串。

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.34%. Comparing base (eb99790) to head (6bde9c0).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
sql/engines/pgsql.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2837      +/-   ##
==========================================
+ Coverage   78.32%   78.34%   +0.02%     
==========================================
  Files         124      124              
  Lines       17524    17548      +24     
==========================================
+ Hits        13725    13748      +23     
- Misses       3799     3800       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LeoQuote
Copy link
Collaborator

这个是不是在 https://github.com/hhyo/Archery/blob/master/common/utils/extend_json_encoder.py 这里注册一个新的类型就行了?

@feiazifeiazi
Copy link
Contributor Author

这个是不是在 https://github.com/hhyo/Archery/blob/master/common/utils/extend_json_encoder.py 这里注册一个新的类型就行了?

你的意思是加
@convert.register(dict)
def _(o):
return json.dumps(o)

@convert.register(list)
def _(o):
return json.dumps(o)

然后靠这里的地方能统一解决? 我试了,不好像。
cls 只能处理 他处理不了未知的类型?

return HttpResponse(
json.dumps(
result,
use_decimal=False,
cls=ExtendJSONEncoderFTime,
bigint_as_string=True,
),
content_type="application/json",
)

@LeoQuote LeoQuote merged commit e94be44 into hhyo:master Oct 18, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PG数据库查询jsonb字段不展示数据
2 participants