Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(contrib/drivers/dm&pgsql&mssql&oracle): add Replace/LastInsertId features support for dm/pgsql/mssql/oracle#4547

Merged
gqcn merged 32 commits intomasterfrom
feat/gdb-mssql-replace
Dec 9, 2025
Merged

feat(contrib/drivers/dm&pgsql&mssql&oracle): add Replace/LastInsertId features support for dm/pgsql/mssql/oracle#4547
gqcn merged 32 commits intomasterfrom
feat/gdb-mssql-replace

Conversation

@gqcn
Copy link
Member

@gqcn gqcn commented Dec 8, 2025

This pull request introduces significant improvements to the handling of the Replace and Save operations for multiple database drivers, especially for MSSQL and PostgreSQL. The changes ensure that these operations now auto-detect primary keys when conflict columns are not explicitly provided, improving usability and aligning behavior across drivers. Additionally, the pull request updates related tests to reflect these enhancements and includes some minor documentation and code cleanup.

Key changes:

Enhanced Replace/Save Logic for Database Drivers

  • MSSQL Driver:

    • Replace and Save operations now auto-detect primary keys if OnConflict is not specified, using the MERGE statement for upsert functionality. If no primary key is found in the data, a detailed error is returned. [1] [2]
    • Updated tests to verify that Replace correctly updates or inserts records, and that missing conflict columns are properly handled. [1] [2]
  • PostgreSQL Driver:

    • Similar to MSSQL, Replace and Save now auto-detect primary keys for conflict resolution if OnConflict is not set, and treat Replace as a Save operation.
    • Adjusted tests to ensure Save and Replace work as expected, including verifying data replacement and insertion. [1] [2] [3]
  • DM Driver:

    • Improved conflict detection: now checks that at least one primary key exists in the provided data when OnConflict is not specified, and provides clearer error messages.
    • Refactored to use the core method for primary key detection and removed redundant code.

Minor Improvements and Documentation

  • Added clarifying comments to DoInsert methods for ClickHouse, DM, MSSQL, Oracle, and PostgreSQL drivers, specifying that the input list must have at least one validated record. [1] [2] [3] [4] [5]
  • Minor code and comment cleanups, including improved formatting and error handling. [1] [2] [3] [4] [5]

Workflow and Documentation Updates

  • Updated example Docker commands in the CI workflow for consistency and clarity. [1] [2] [3] [4] [5] [6]
  • Removed outdated note about Replace support from the SQLite driver documentation.

These changes improve the consistency, reliability, and developer experience when performing upsert operations across different database backends.

This comment was marked as outdated.

LanceAdd and others added 6 commits December 8, 2025 16:48
`gf gen
dao`生成`entity`时支持数据库`uuid`类型字段生成`github.com/google/uuid`的`uuid.UUID`类型字段
Copy link
Contributor

Copilot AI commented Dec 8, 2025

@gqcn I've opened a new pull request, #4550, to work on those changes. Once the pull request is ready, I'll request review from you.

@gqcn gqcn changed the title feat(contrib/drivers/pgsql&mssql): add Replace support for pgsql/mssql feat(contrib/drivers/pgsql&mssql&oracle): add Replace support for pgsql/mssql/oracle Dec 9, 2025
@gqcn gqcn requested a review from Copilot December 9, 2025 01:22

This comment was marked as outdated.

@gqcn gqcn changed the title feat(contrib/drivers/pgsql&mssql&oracle): add Replace support for pgsql/mssql/oracle feat(contrib/drivers/pgsql&mssql&oracle): add Replace/LastInsertId features support for pgsql/mssql/oracle Dec 9, 2025
@gqcn gqcn changed the title feat(contrib/drivers/pgsql&mssql&oracle): add Replace/LastInsertId features support for pgsql/mssql/oracle feat(contrib/drivers/dm&pgsql&mssql&oracle): add Replace/LastInsertId features support for pgsql/mssql/oracle Dec 9, 2025
@gogf gogf deleted a comment from Copilot AI Dec 9, 2025
@gqcn gqcn requested a review from Copilot December 9, 2025 06:04
@gqcn gqcn changed the title feat(contrib/drivers/dm&pgsql&mssql&oracle): add Replace/LastInsertId features support for pgsql/mssql/oracle feat(contrib/drivers/dm&pgsql&mssql&oracle): add Replace/LastInsertId features support for dm/pgsql/mssql/oracle Dec 9, 2025
@gqcn gqcn merged commit 852c3dd into master Dec 9, 2025
20 checks passed
@gqcn gqcn deleted the feat/gdb-mssql-replace branch December 9, 2025 07:46
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.

4 participants