Develop#2
Conversation
…RE clause This commit introduces a convenience feature where the first logical operation (`AND` or `OR`) is automatically used as the `WHERE` clause if one is not explicitly set in the query builder. This simplifies query construction by removing the requirement to call `where()` first. The changes include: - Modifying the `build()` method in `QuerySelect.Builder` and `QueryDelete.Builder` to automatically identify and set the `WHERE` clause from the existing logical operations. - Updating `getSqlOperators()` in `QuerySelect`, `QueryDelete`, and `QueryUpdate` to correctly include the `where` operator in the returned list, improving query introspection.
This commit corrects a test case for `QueryDelete`. The test `build without where clause throws exception` was incorrectly including a WHERE condition, which prevented it from accurately verifying that building a `QueryDelete` without any conditions throws an `IllegalArgumentException`. The extraneous condition has been removed.
|
merge pull |
|
@copilot puedes revisar y aprobar este PR |
|
@LeandroLCD I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the query builder classes to change how WHERE clauses are handled and how SQL operators are collected. The main changes introduce a fallback mechanism that allows operations (AND/OR conditions) to be promoted to the WHERE clause when no explicit WHERE is set, and updates the getSqlOperators() method to include the WHERE clause in the returned list.
- Modified
getSqlOperators()in QueryDelete, QuerySelect, and QueryUpdate to include the WHERE clause in the returned list - Added fallback logic in QueryDelete and QuerySelect builders to automatically use the first operation as WHERE clause when none is explicitly set
- Updated test to remove
.and()call from the "build without where clause" test case
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| query/src/main/java/com/blipblipcode/query/QueryDelete.kt | Updated getSqlOperators() to include WHERE clause and added fallback logic in build() to use first operation as WHERE when not explicitly set |
| query/src/main/java/com/blipblipcode/query/QuerySelect.kt | Updated getSqlOperators() to include WHERE clause and added fallback logic in build() to use first operation as WHERE when not explicitly set |
| query/src/main/java/com/blipblipcode/query/QueryUpdate.kt | Changed getSqlOperators() to return the WHERE clause instead of an empty list |
| query/src/test/java/com/blipblipcode/query/QueryDeleteTest.kt | Removed .and() call from test that validates exception is thrown when building without WHERE clause |
Comments suppressed due to low confidence (1)
query/src/test/java/com/blipblipcode/query/QueryDeleteTest.kt:49
- This test no longer validates that building without a WHERE clause throws an exception. The removal of the
.and()call means the test now checks if building with an empty builder throws an exception, which is different from the original intent of ensuring a WHERE clause is required even when other operations are present. The test name suggests it should verify that a WHERE clause is required, but with the code changes inbuild()that allow falling back to operations, this test case may no longer be testing the right behavior. Consider updating the test to match the new behavior or reverting the behavior change in the build method.
fun `build without where clause throws exception`() {
val builder = QueryDelete.builder("users")
assertThrows(IllegalArgumentException::class.java) {
builder.build()
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@LeandroLCD I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you. |
No description provided.