Skip to content

Conversation

@cofin
Copy link
Member

@cofin cofin commented Oct 30, 2025

Introduce integration and unit tests for the MERGE statement, covering various scenarios and edge cases. Enhance the MERGE functionality for the PostgreSQL dialect by adding JSON support and refactoring SQL builder methods for improved efficiency.

@cofin cofin force-pushed the feat/merg-upsert-builder branch from f82bbff to e699c33 Compare October 31, 2025 02:04
cofin added 9 commits October 31, 2025 13:40
- Implement integration tests for MERGE with AsyncPG and Oracle, covering various scenarios including updates, inserts, and conditional logic.
- Introduce unit tests for the MERGE builder, validating the construction of SQL statements and parameter handling.
- Refactor the WHERE clause handling in the SQL builder to utilize a more efficient expression method.
- Ensure comprehensive coverage of edge cases, including NULL values and complex conditions in MERGE operations.
Fixes NULL value handling in MERGE statements by scanning all records
for non-NULL values and defaulting to NUMERIC type when all values are NULL.

Changes:
- Scan all source records to find first non-NULL value per column
- Default NULL-only columns to NUMERIC instead of TEXT for better compatibility
- Add comprehensive MERGE documentation to builder reference
- All 51 tests passing (34 unit + 17 integration)

The previous implementation defaulted NULL values to TEXT type, causing
type mismatch errors when merging into NUMERIC columns. Now uses the same
pattern as Oracle implementation to scan all records for type inference.

Resolves test_asyncpg_merge_with_null_values failure.
…lder

Resolves all type checker errors blocking merge:
- Added explicit type annotations for Expression variables
- Fixed list/dict type narrowing with if/else blocks
- Fixed async generator return type in test fixture
- Added None checks for optional attribute access

All 51 tests passing, mypy and pyright clean.
…improve type annotations in parsing utilities
…dialects

- Implement tests for MERGE functionality in MySQL, SQLite, DuckDB, PostgreSQL, Oracle, and BigQuery.
- Validate error handling for unsupported dialects and suggest alternatives.
- Create tests for the sql.merge_ property to ensure it returns a new Merge builder instance.
- Add tests for the to_sql() method, covering various parameter types and edge cases.
- Introduce tests for the sql.upsert() factory method, ensuring correct behavior for different dialects and edge cases.
- Ensure backward compatibility and proper handling of complex table names and quoted identifiers.
… across async and sync drivers, and adjust related tests
@cofin cofin force-pushed the feat/merg-upsert-builder branch from 9ea2674 to 7556f95 Compare October 31, 2025 18:40
cofin added 9 commits October 31, 2025 18:40
…ed serialization in AsyncPG and Psycopg drivers
- Removed direct usage of type converters in ADBC, BigQuery, DuckDB, and Psycopg adapters to streamline type coercion.
- Introduced helper functions for preparing list and tuple parameters in Psycopg and DuckDB to handle JSON serialization.
- Enhanced Psqlpy driver with new methods for normalizing parameters, including handling of Decimal types and scalar conversions.
- Updated SQLProcessor to track placeholder positions for better parameter handling.
- Improved test cases for bulk merge operations in Psqlpy and OracleDB, ensuring compatibility with float types instead of Decimal.
- Cleaned up unused imports and optimized code for clarity and maintainability.
@cofin cofin merged commit d59d561 into main Nov 2, 2025
15 checks passed
@cofin cofin deleted the feat/merg-upsert-builder branch November 2, 2025 01:10
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.

2 participants