Skip to content

develop#6

Merged
LeandroLCD merged 10 commits into
masterfrom
develop
Nov 20, 2025
Merged

develop#6
LeandroLCD merged 10 commits into
masterfrom
develop

Conversation

@LeandroLCD

Copy link
Copy Markdown
Owner

Se agregan ordenamiento multible, se agregan test.

LeandroLCD and others added 10 commits November 17, 2025 20:37
…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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit modifies `QuerySelect` to support SQL queries without a `WHERE` clause.

Previously, the `WHERE` clause was mandatory. This restriction has been lifted, but the requirement is maintained if other logical operations (like `AND` or `OR`) are present.

The main changes include:
- The `where` property in `QuerySelect` is now nullable (`SQLOperator<*>?`).
- The `build()` method in the `QuerySelect.Builder` now only requires a `WHERE` clause if subsequent logical operations are added.
- The SQL generation in `asSql()` has been updated to correctly build the `SELECT` statement when no `WHERE` clause is provided.
- `getSqlOperators()` is updated to handle the nullable `where` property.
# Conflicts:
#	query/src/main/java/com/blipblipcode/query/QuerySelect.kt
Updates the Android Gradle Plugin version from 8.13.0 to 8.13.1.

feat(Query): Enhance `orderBy` and fix `like` operator

This commit introduces several improvements to the query builder, focusing on `ORDER BY` clause handling and correcting the behavior of the `like` operator.

Key changes include:

*   **Fix `like` Operator Logic**: The `like()` method in `QuerySelect` and `QueryDelete` builders was incorrectly using a `LIKE` logical type. This has been corrected to use the `AND` logical type, ensuring it chains correctly with other conditions. The method signature is now restricted to `SQLOperator.Like`.

*   **Enhanced `OrderBy` in Union and Join Queries**: `UnionQuery` and `InnerJoint` now correctly handle `ORDER BY` clauses. They aggregate `OrderBy` operators from all subqueries, clear them from the individual queries, and apply a combined `OrderBy` to the final result set. This prevents SQL errors and ensures predictable sorting. `QuerySelect` has been updated with `getOrderBy()` and nullable `orderBy()` methods to support this.

*   **Improved `OrderBy` Implementation**:
    *   A new `OrderBy.Multiple` sealed class has been added to handle sorting by multiple columns with different sort directions.
    *   The `asSqlClause()` method was introduced for more flexible SQL string generation.

*   **Extensive Testing**: Added comprehensive unit tests for the `orderBy` functionality in `QuerySelectTest`, covering various scenarios like single and multiple columns, mixed sort directions, aliases, and combinations with `LIMIT`.
This commit corrects the KDoc for the `orderBy` function in `UnionQuery`.

The `@param` name has been updated from `columns` to `operator` to accurately match the function's parameter name.
@LeandroLCD
LeandroLCD merged commit 9a5c9b9 into master Nov 20, 2025
1 check passed
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.

1 participant