Skip to content

develop#7

Merged
LeandroLCD merged 11 commits into
masterfrom
develop
Nov 26, 2025
Merged

develop#7
LeandroLCD merged 11 commits into
masterfrom
develop

Conversation

@LeandroLCD

Copy link
Copy Markdown
Owner

Se agrega soporte para agregar Lower y Upper al SQLOperator

LeandroLCD and others added 11 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.
This commit introduces support for case-insensitive comparisons in SQL operators by adding an optional `CaseConversion` parameter. This allows wrapping columns and values with `LOWER()` or `UPPER()` SQL functions.

The main changes include:

*   **New `CaseConversion` Enum**: A new enum `CaseConversion` (`NONE`, `LOWER`, `UPPER`) has been created to specify the desired case conversion.
*   **Updated `SQLOperator`**:
    *   The `SQLOperator` interface and all its implementing data classes now include a `caseConversion` property, which defaults to `NONE`.
    *   The `toSQLString()` methods have been updated to apply the corresponding SQL function (`LOWER()` or `UPPER()`) to both the column and the value when a conversion is specified.
*   **New Test Cases**: Added tests to `QuerySelectTest` to verify the correct SQL generation for queries using `UPPER` case conversion in the `WHERE` clause.
@LeandroLCD
LeandroLCD merged commit ef8c89e into master Nov 26, 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