Skip to content

develop#16

Merged
LeandroLCD merged 50 commits into
masterfrom
develop
Jun 18, 2026
Merged

develop#16
LeandroLCD merged 50 commits into
masterfrom
develop

Conversation

@LeandroLCD

Copy link
Copy Markdown
Owner

Release 0.13.3
Se agrega pipeline para generar la release de forma automatica.

LeandroLCD and others added 30 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.
This commit updates the following dependencies to their latest versions:

*   Kotlin: `2.0.21` -> `2.2.21`
*   AndroidX Lifecycle Runtime KTX: `2.9.4` -> `2.10.0`
*   AndroidX Activity Compose: `1.11.0` -> `1.12.1`
*   AndroidX Compose BOM: `2024.09.00` -> `2025.12.00`
*   AndroidX SQLite KTX: `2.6.1` -> `2.6.2`
This commit updates the Kotlin version badge in the `README.md` file.

The version has been changed from `1.9+` to `2.2.21+` to reflect the current Kotlin version used in the project.
This commit refactors the `Field` data class to implement the `SQLOperator<T>` interface, standardizing its structure with other operators.

The main changes include:
-   Implementing `SQLOperator` in `Field`, providing `symbol`, `column`, `value`, and `caseConversion` properties.
-   Updating the `asString()` method to use the newly added `symbol` property for SQL generation.
-   Adding a `clone()` method to the `OrderBy` sealed class and its subclasses (`Asc`, `Desc`, `Multiple`) to allow for deep cloning of instances, which improves immutability and flexibility in query construction.
-   Fixing the `IN` and `NOT IN` operators in `SQLOperator.kt` by ensuring that string values within the list are correctly quoted in the generated SQL.
This commit enhances the `Queryable` interface by adding a new overloaded `asSql` method.

The new method accepts a predicate lambda, which allows for filtering the `SQLOperator`s that are included when generating the final SQL string. This provides more control and flexibility in SQL generation.
…nality

This commit introduces two main enhancements to the query builder classes: a new `asSql` method that accepts a predicate for filtering SQL operators, and a `clear` method for resetting query builders.

The key changes include:

*   **Predicate-based `asSql(predicate)` Method**:
    *   All `Queryable` classes (`QuerySelect`, `QueryInsert`, `QueryUpdate`, `QueryDelete`, `UnionQuery`, `InnerJoint`) now implement an overloaded `asSql` method.
    *   This new method takes a predicate lambda, allowing for the conditional inclusion of SQL operators when generating the final SQL string.

*   **`clear()` Method for Builders**:
    *   `QuerySelect` and `QueryDelete` (and their respective builders) now feature a `clear()` method.
    *   This method resets the query state by removing the `WHERE` clause and any subsequent logical operations (`AND`, `OR`), allowing builders to be reused for new queries.
This commit refactors `Limit`, `OrderBy`, `IsNull`, and `IsNotNull` to fully implement the `SQLOperator` interface. This standardization improves consistency across all SQL operators.

Key changes include:

*   **`Limit` and `OrderBy` Implementation**:
    *   `Limit` and the sealed interface `OrderBy` (including `Asc`, `Desc`, and `Multiple`) now implement `SQLOperator`.
    *   They now define standard properties like `symbol`, `column`, `value`, and `caseConversion`.
    *   The `asString()` methods have been updated to use these properties for SQL generation.

*   **`IsNull` and `IsNotNull` Adjustments**:
    *   The generic type for `IsNull` and `IsNotNull` has been changed from `Unit` to `String?`, with the `value` property now returning `null`.
    *   Their `toSQLString()` and `asString()` methods have been updated to support case conversion on the column.
This commit introduces `RepeatedQueryParameters`, a custom `LinkedHashMap` implementation designed to handle repeated query parameters in Retrofit.

This utility class allows lists provided as values in a `@QueryMap` to be automatically expanded into multiple query parameters with the same key. This is useful for API endpoints that expect repeated keys, such as `?key=value1&key=value2`.

Key features:
- **`RepeatedQueryParameters` class**: Extends `LinkedHashMap` and overrides the `entries` property to transform list values into multiple `Map.Entry` objects.
- **Factory methods**: Provides `create()`, `fromMap()`, and `empty()` for convenient instantiation.
- **Handles lists**: Automatically expands `List<*>` values into separate key-value pairs.
- **Null safety**: Throws exceptions for null keys and skips null values within lists.
This commit introduces a new extension function, `asQueryRepeatedQueryParameters`, for the `Queryable` interface. This function converts the SQL operators of a query into a `RepeatedQueryParameters` object, which is useful for integrations like Retrofit.

Key features include:
- A `predicate` parameter to conditionally filter which query parameters are included.
- Support for regular parameters and repeated parameters (from `List` values).
- Null-valued parameters are automatically excluded.
This commit enhances the `getSqlOperators()` method in `QuerySelect`.

The `orderBy` and `limit` operators are now included in the returned list of SQL operators. This improves query introspection by providing a more complete representation of the query's components.
This commit introduces `RepeatedQueryParameters`, a utility class designed to bridge the gap between the `Query` library and Retrofit's `@QueryMap` annotation. It also adds a convenient extension function to convert `Queryable` objects directly into this new format.

The key changes include:

*   **New `RepeatedQueryParameters` class**:
    *   This class extends `LinkedHashMap` and is designed to handle both single and repeated query parameters, which are common in REST APIs.
    *   It provides `addParameter()` for single values and `addRepeatedParameter()` for lists.
    *   A custom `entries` property expands list values into multiple `Map.Entry` objects, making it compatible with Retrofit's `@QueryMap` when used for repeated parameters (e.g., `?key=val1&key=val2`).

*   **New `asQueryRepeatedQueryParameters()` extension function**:
    *   This function converts any `Queryable` object (like `QuerySelect`) into a `RepeatedQueryParameters` instance.
    *   It intelligently handles `SQLOperator` values, mapping single values directly and converting list-based operators (like `IN`) into repeated parameters.
    *   Operators with `Unit` or `null` values (e.g., `IsNull`) are automatically filtered out.
    *   An optional predicate allows for custom filtering of which operators are included.

*   **Comprehensive Unit Tests**:
    *   Added `RepeatedQueryParametersTest.kt` to thoroughly validate the new class's behavior, including adding, overwriting, and expanding parameters.
    *   Added `QueryableRepeatedQueryParametersExtensionTest.kt` to test the conversion from `Queryable` to `RepeatedQueryParameters`, covering simple operators, list-based operators, and filtering logic.
This commit introduces `RepeatedQueryParameters`, a utility class designed to bridge the gap between the `Query` library and Retrofit's `@QueryMap` annotation. It also adds a convenient extension function to convert `Queryable` objects directly into this new format.

The key changes include:

*   **New `RepeatedQueryParameters` class**:
    *   This class extends `LinkedHashMap` and is designed to handle both single and repeated query parameters, which are common in REST APIs.
    *   It provides `addParameter()` for single values and `addRepeatedParameter()` for lists.
    *   A custom `entries` property expands list values into multiple `Map.Entry` objects, making it compatible with Retrofit's `@QueryMap` when used for repeated parameters (e.g., `?key=val1&key=val2`).

*   **New `asQueryRepeatedQueryParameters()` extension function**:
    *   This function converts any `Queryable` object (like `QuerySelect`) into a `RepeatedQueryParameters` instance.
    *   It intelligently handles `SQLOperator` values, mapping single values directly and converting list-based operators (like `IN`) into repeated parameters.
    *   Operators with `Unit` or `null` values (e.g., `IsNull`) are automatically filtered out.
    *   An optional predicate allows for custom filtering of which operators are included.

*   **Comprehensive Unit Tests**:
    *   Added `RepeatedQueryParametersTest.kt` to thoroughly validate the new class's behavior, including adding, overwriting, and expanding parameters.
    *   Added `QueryableRepeatedQueryParametersExtensionTest.kt` to test the conversion from `Queryable` to `RepeatedQueryParameters`, covering simple operators, list-based operators, and filtering logic.
This commit enhances the KDoc for the `getOrderBy()` function in the `QuerySelect` builder.

The new documentation clarifies that the function returns the `OrderBy` object for the query, or `null` if an `ORDER BY` clause has not been set.
This commit fixes a bug in the `Between` SQL operator where the start and end values were not being properly quoted in the generated SQL string. This could lead to SQL syntax errors when using string values.

The `toSQLString()` and `asString()` methods in `SQLOperator.Between` have been updated to enclose the start and end values in single quotes.
feat(Query): Enhance `QuerySelect` and `UnionQuery` with builders and transformations

This commit introduces several improvements to the query building API, focusing on query mutability and builder reusability.

Key changes include:

*   **Enhanced `QuerySelect`**:
    *   Added `newBuilder()` to create a builder from an existing query instance, facilitating query modification.
    *   Updated `where` clause storage to use a `Pair<String, SQLOperator<*>>` to support keyed identification of the primary condition.
    *   Added `getOperations()` to retrieve a map of all SQL operators (including WHERE) indexed by their keys.
    *   Introduced `transformOperation(key, transform)` in `QueryBuilder` to allow modifying specific logical operations by key.

*   **Improved `UnionQuery`**:
    *   Renamed `UnionQuery.Builder` to `UnionQuery.QueryBuilder` for consistency.
    *   Added `newBuilder()` to allow extending or modifying existing union queries.
    *   Implemented `transformOperation(key, transform)` in the union builder, which applies the transformation recursively to all subqueries in the union.

*   **Bug Fixes & Refactoring**:
    *   Corrected `QuerySelect` SQL generation to handle the updated `where` pair structure.
    *   Updated the `UnionQuery.addQuery` extension function to use the renamed `QueryBuilder`.
This commit cleans up the `UnionQuery.kt` file by removing several unused imports, including `QuerySelect.QueryBuilder`, `LogicalType`, and `kotlin.collections.set`.
LeandroLCD and others added 20 commits January 22, 2026 11:41
This commit refactors the `LogicalOperation` class into a sealed interface with distinct implementations for each logical type (`Where`, `And`, `Or`, `Not`, etc.). This improves type safety and aligns the structure with other operator models in the library.

The key changes include:

*   **`LogicalOperation` as a Sealed Interface**: Replaced the previous data class with a sealed interface, providing specific data classes for each logical operation (`Where`, `And`, `Or`, etc.).
*   **Standardized Structure**: Each `LogicalOperation` implementation now includes `symbol`, `operator`, `asString()`, and `clone()` members for consistency.
*   **Updated Query Builders**: `QuerySelect.QueryBuilder` and `QueryDelete.QueryBuilder` have been updated to use the new sealed interface implementations, replacing the previous `LogicalType` enum.
*   **Refined SQL Generation**: The `asSql()` methods in `QuerySelect` and `QueryDelete` now delegate the generation of the `WHERE` clause to the `LogicalOperation.Where.asString()` method, simplifying the logic.
# Conflicts:
#	query/src/main/java/com/blipblipcode/query/QuerySelect.kt
- Upgrades the Android Gradle Plugin (AGP) from version 8.13.2 to 9.0.0.
- Updates the Gradle wrapper to version 9.3.1.
- Removes the now-redundant `kotlin.android` plugin from build scripts, as it's included in AGP 9.0.
- Adjusts build script structures to align with the new AGP version by moving the `kotlin` block.
- Adds `limit` and `orderBy` to the operations map and exposes a `getLimit()` method in `QuerySelect`.
Updates several dependencies to their newer versions:
- Kotlin from 2.2.21 to 2.3.10
- Activity Compose from 1.12.1 to 1.12.4
- Compose BOM from 2025.12.00 to 2026.02.00

Additionally, removes the unused `kotlin-android` plugin definition from the `[plugins]` section.
Updates several dependencies to their newer versions:
- coreKtx from 1.17.0 to 1.18.0
- activityCompose from 1.12.4 to 1.13.0
- composeBom from 2026.02.00 to 2026.03.00
- Adds `getOperators()` to `QuerySelect` to retrieve a list of all `SQLOperator` instances from current operations.
- Implements `clearOrderBy()` in both `QuerySelect` and `UnionQuery` to reset the `orderBy` field.
- Introduces a `Collation` sealed interface to handle SQL `COLLATE` clauses (e.g., `NOCASE`, `BINARY`, `RTRIM`) and custom collation names.
- Updates `OrderBy.Asc` and `OrderBy.Desc` to support `collation` and a `transform` function for wrapping columns in SQL functions like `REPLACE`.
- Adds `CollationUtils.removeCharsTransform()` to easily generate chained `REPLACE` calls for sanitizing sort keys.
- Refactors `UnionQuery` to wrap internal queries in a subquery `SELECT * FROM (...)` when using `ORDER BY`, preventing syntax errors with combined results.
- Updates `QuerySelect.asSql` to allow predicate filtering on `OrderBy` and `Limit` operations.
- Adds comprehensive tests for collation, character removal transformations, and `UnionQuery` sorting behavior.
- Updates documentation in `README.md` with examples for new sorting features.
…nQuery

- Introduces `limit()` and `clearLimit()` to `UnionQuery` to apply or remove limit constraints across all internal queries.
- Refactors `UnionQuery.asSql()` to ensure that a top-level `orderBy` takes precedence, ignoring internal query sort orders when set.
- Adds `clearLimit()` to `QuerySelect` to allow resetting the `LIMIT` clause.
- Implements `QuerySelectBuilder` test utility for more fluent test case construction.
- Adds comprehensive unit tests for `limit` propagation and `orderBy` precedence within `UnionQuery`.
- Implements `toQueryDelete()` in `QuerySelect` to convert a select query into a delete query targeting the same table.
- Ensures that `WHERE` and subsequent logical operations (`AND`/`OR`) are preserved during the conversion.
- Adds a requirement for a `WHERE` clause to be present before conversion to prevent accidental full-table deletions.
- Updates extension imports to support the new query conversion functionality.
# Conflicts:
#	query/build.gradle.kts
#	query/src/main/java/com/blipblipcode/query/QuerySelect.kt
- Introduces a `Copyable` interface to standardize deep cloning across SQL and logical operators.
- Implements `clone()` in `SQLOperator` (Equals, NotEquals, Like, In, Between, etc.), `LogicalOperation`, `Field`, and `Limit` to ensure independent instances when modifying queries.
- Refactors `OrderBy` cloning to use explicit `copy()` extension methods, simplifying the API and removing unsafe `vararg` parameters.
- Fixes `QuerySelect.newBuilder()` to correctly clone the operations map, preventing unintended side effects on the original query.
- Adds an `andNot(key, operator)` overload to `QuerySelect.QueryBuilder` for keyed logical operation management.
- Implements comprehensive unit tests for query cloning, transformation, and state maintenance.
- Standardizes test naming and structure following a new `TESTING_GUIDELINES.md` (snake_case, Given-When-Then, `runCatching` for exceptions).
- Updates `Between` operator SQL generation to correctly handle string conversions and spacing.
…lOperation` and `OrderBy`

- Renames `LogicalOperation.copy()` to `copyOperation()` and `OrderBy.copy()` to `copyOrderBy()` to avoid shadowing or conflicting with data class generated `copy` methods.
- Fixes `copyOperation()` implementation for `Multiple` logical operations to correctly update the first operation in the list.
- Fixes `copyOperation()` for all other `LogicalOperation` types by explicitly invoking constructors instead of relying on recursive `copy()` calls.
- Updates `QuerySelectTest` and `CopyTest` to use the newly renamed extension methods.
- Adds KDoc documentation to both extension methods to clarify their purpose and parameters.
- Updates Android Gradle Plugin (AGP) from 9.0.0 to 9.0.1.
- Sets the project version to `0.13.3` in the root `build.gradle.kts`.
- Introduces a comprehensive GitHub Actions release pipeline (`release-pipeline.yml`) triggered by Pull Requests to `master`.
- The new pipeline automates:
    - Running unit tests for the `:query` module.
    - Validating semantic versioning and ensuring the tag does not already exist.
    - Building the release AAR artifact upon merging.
    - Creating a GitHub Release with the attached AAR and a generated changelog.
    - Monitoring the JitPack build status and logging.
    - Posting a summarized status report as a comment on the PR.
@github-actions

Copy link
Copy Markdown

🧪 Unit Test Report — :query module

185 tests   185 ✅  0s ⏱️
  9 suites    0 💤
  9 files      0 ❌

Results for commit 847b6f7.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

🚀 Release Pipeline — Resumen

# Paso Estado Detalle
1️⃣ Unit Tests success Tests unitarios del módulo :query
2️⃣ Check Tag & Bump success primer release: v0.13.3
3️⃣ Build Release AAR success ./gradlew :query:assembleRelease
4️⃣ GitHub Release success Tag v0.13.3 + AAR · Ver GitHub Release
5️⃣ JitPack Build success 📄 Build Log · Status: ok

📌 Versión nueva: 0.13.3  ·  🏷️ Último tag: ninguno
🔀 Estado:Mergeado — pipeline completo ejecutado

📥 Dependency (JitPack)

// settings.gradle.kts
maven { url = uri("https://jitpack.io") }

// build.gradle.kts
implementation("com.github.LeandroLCD:android-sql-query:0.13.3")

🤖 Generado automáticamente por el Release Pipeline · Run #2

@LeandroLCD
LeandroLCD merged commit 048c0cc into master Jun 18, 2026
7 checks 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