-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: enhance MERGE functionality #217
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f82bbff to
e699c33
Compare
- 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
…tion tests for consistent field naming
9ea2674 to
7556f95
Compare
…pytest marks for consistency
…rivers and utilities for consistency
…ove JSON handling in AsyncPG
…clarity in SQLite integration tests
…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.
…arameter extraction in ParameterConverter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.