Feature/field to field comparison#134
Merged
brunomendola merged 25 commits intoqueritylib:mainfrom Dec 15, 2025
Merged
Conversation
- Add Select interface and SimpleSelect implementation - Add NativeSelectWrapper for native select support - Add hasSelect() and getSelect() to Query - Add selectBy() method to QueryBuilder (renamed from select to avoid Jackson conflict) - Add findAllProjected() method to Querity interface with default implementation - Implement projection support in JPA module (JpaSelect, JpaSimpleSelect, JpaQueryFactory) - Implement projection support in MongoDB module (MongodbSelect, MongodbSimpleSelect, MongodbQueryFactory) - Implement projection support in Elasticsearch module (ElasticsearchSelect, ElasticsearchSimpleSelect, ElasticsearchQueryFactory) - Add SELECT keyword to parser grammar - Add SelectUtils for native select wrapper resolution - Add tests for select in spring-web module Note: Using SimpleSelect (concrete class) instead of Select (interface) in Query to avoid Jackson deserialization issues with polymorphic types.
- Add SimpleSelectTest for API module - Add JpaSelectTests for JPA module - Add parser tests for SELECT keyword in QuerityParserTests
- Create SelectDeserializer following the same pattern as ConditionDeserializer - Register SelectDeserializer in QuerityModule - Change Query.select from SimpleSelect to Select interface - Add getPropertyNames() method to Select interface - Update JpaSelect, MongodbSelect, ElasticsearchSelect to accept Select interface - Update QueryVisitor to use Select interface This approach is more consistent with how Condition is handled and allows for proper polymorphic deserialization of Select implementations.
- Create SortDeserializer following the same pattern as ConditionDeserializer and SelectDeserializer - Register SortDeserializer in QuerityModule - Remove @JsonTypeInfo/@JsonSubTypes annotations from Sort interface Now all three interfaces (Condition, Select, Sort) use custom deserializers registered in QuerityModule for consistent and predictable JSON parsing.
- Add NativeSelectWrapperTest for API module - Add DeserializerTests for SelectDeserializer and SortDeserializer - Add test for unsupported Select type in JpaSelectTests - Coverage improvements: - querity-api: 98% - querity-spring-web: 99% - querity-jpa-common: 78%
- Add DateValueExtractorTests for Date value extraction - Add SelectUtilsTests for NativeSelectWrapper handling - Add SpecificationTests for JPA Specification.where() - Add projection tests for Elasticsearch, MongoDB, and JPA - Add additional parser tests for edge cases - Fix DeserializerTests assertions for exception handling - Extend JpaSelectTests with NativeSelectWrapper tests - Configure JaCoCo to exclude ANTLR generated classes
- Add SelectTests to QuerityGenericTestSuite with tests for selectBy - Add SelectionSpecification interface for native JPA selection expressions - Add AliasedSelectionSpecification for selections with custom aliases - Add JpaSelectionSpecificationSelectWrapper for native select support - Add selectByNative tests with concat expression in JPA test classes - Add sortByNative test with expression (cb.length) in JPA test classes - Update README with documentation for projections and native expressions - Update JpaSelect interface to include CriteriaBuilder parameter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds the ability to compare one field against another field in where conditions. This enables queries like "startDate < endDate" or "firstName = lastName". Features: - New FieldReference class to represent field references in conditions - Query language support with $ prefix syntax (e.g., startDate < $endDate) - JSON API support with fieldRef property - JPA implementation using CriteriaBuilder path comparisons - MongoDB implementation using $expr with comparison operators - Elasticsearch throws UnsupportedOperationException (not supported natively) Supported operators for field-to-field comparison: - EQUALS, NOT_EQUALS - GREATER_THAN, GREATER_THAN_EQUALS - LESSER_THAN, LESSER_THAN_EQUALS Operators that don't support field references: - STARTS_WITH, ENDS_WITH, CONTAINS - IS_NULL, IS_NOT_NULL - IN, NOT_IN 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
MongoDB $expr comparisons include null values because null is considered
"less than" any value. Added fieldToFieldComparisonIncludesNulls() method
to allow MongoDB tests to correctly filter expected results.
Also fixed Javadoc formatting in FieldReference to use {@code} tags.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documentation: - Enhanced FieldReference Javadoc with supported/unsupported operators, backend support matrix, nested fields, query language syntax, JSON API - Added SimpleCondition class-level Javadoc explaining field-to-field usage - Improved Querity.field() and filterByField() method documentation Tests: - Added nested field comparison tests (address.city vs firstName) - Added NOT condition with nested field reference test - Tests verify both left-side and right-side nested field paths work 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- givenSelectByTwoFields: relax lastName assertion (null values may be excluded from projections in MongoDB/Elasticsearch) - givenSelectByNestedField: accept both flat 'city' and nested 'address.city' structures (Elasticsearch returns nested structure) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…docs. All tests pass. [2025-12-07]
- Relocate selectByNative tests from SpringPostgresqlQuerityJpaImplTests to QuerityJpaImplTests - Tests validate SQL database behavior generally, not Postgres-specific edge cases - Enhance givenSelectByTwoFields test with lastName IS_NOT_NULL filter - Restore lastName containsKey assertion for more robust validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
# Conflicts: # querity-parser/src/test/java/io/github/queritylib/querity/parser/QuerityParserTests.java # querity-spring-web/src/test/java/io/github/queritylib/querity/spring/web/jackson/DeserializerTests.java # querity-test/src/main/java/io/github/queritylib/querity/test/QuerityGenericTestSuite.java
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
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.
No description provided.