enhance: add Save
operation support for pgsql #3053
#3324
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolved #3053
Dear reviewer:
增加对 PgSQL 的
gbd.save
支持,使用ON CONFLICT
子句实现变更的方法
type DB interface
新增DoFormatUpsert
它用作替代原有
formatOnDuplicate
写死的方法,用以格式化处理不同数据库 upsert 的实现,它可以被 driver 覆盖。 比如 mysql 处理成ON DUPLICATE KEY UPDATE ...
, PgSQL 格式化成ON CONFLICT ...
公开
gdb.core
的isSoftCreatedFieldName
它用作
save
更新时忽略created_at
,以便提供给DoFormatUpsert
使用gbd.Model
新增OnConflict
链式方法部分数据库
upsert
时可能需要指定冲突键,PgSQL 中使用ON CONFLICT(id)
备注
合并后, 需要更新文档。