Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a595b16
feat(Query): Automatically use the first logical operation as the WHE…
LeandroLCD Nov 17, 2025
20e71ac
test(QueryDelete): Fix test for building without a WHERE clause
LeandroLCD Nov 17, 2025
6edf9d8
Update query/src/main/java/com/blipblipcode/query/QueryDelete.kt
LeandroLCD Nov 17, 2025
cd823c1
Update query/src/main/java/com/blipblipcode/query/QuerySelect.kt
LeandroLCD Nov 18, 2025
0ef87ec
feat(QuerySelect): Allow queries without a WHERE clause
LeandroLCD Nov 18, 2025
5899c58
Merge remote-tracking branch 'origin/master' into develop
LeandroLCD Nov 18, 2025
8cb9e02
Merge branch 'master' into develop
LeandroLCD Nov 18, 2025
5200a40
Merge remote-tracking branch 'origin/develop' into develop
LeandroLCD Nov 20, 2025
ac5b7fb
chore(deps): Update AGP to 8.13.1
LeandroLCD Nov 20, 2025
c0b92b6
docs(UnionQuery): Fix KDoc for orderBy parameter
LeandroLCD Nov 20, 2025
664d910
feat(Query): Add case-insensitive comparison support
LeandroLCD Nov 26, 2025
8bb0d5a
chore(deps): Update various dependencies
LeandroLCD Dec 8, 2025
c4c208f
chore(README): Update Kotlin version badge
LeandroLCD Dec 8, 2025
8b3be0d
refactor(Field): Implement SQLOperator for consistency
LeandroLCD Dec 8, 2025
8a9c3e0
feat(Queryable): Add filtered `asSql` method
LeandroLCD Dec 8, 2025
8f41579
feat(Queryable): Add predicate-based SQL generation and clear functio…
LeandroLCD Dec 8, 2025
4d6156b
refactor(SQLOperator): Standardize operator implementations
LeandroLCD Dec 8, 2025
e667492
feat(retrofit): Add RepeatedQueryParameters for Retrofit @QueryMap
LeandroLCD Dec 8, 2025
d797d6d
feat(Queryable): Add `asQueryRepeatedQueryParameters` extension
LeandroLCD Dec 8, 2025
a5d00b2
feat(QuerySelect): Include orderBy and limit in getSqlOperators
LeandroLCD Dec 8, 2025
ed4e44c
feat(Retrofit): Add `RepeatedQueryParameters` for Retrofit integration
LeandroLCD Dec 8, 2025
c1cd2e1
feat(Retrofit): Add `RepeatedQueryParameters` for Retrofit integration
LeandroLCD Dec 8, 2025
880424b
Merge branch 'master' into develop
LeandroLCD Dec 9, 2025
97bbc8b
docs(QuerySelect): Improve KDoc for getOrderBy function
LeandroLCD Dec 9, 2025
27c6476
Add Retrofit badge and update README links
LeandroLCD Dec 9, 2025
c7f40a6
fix(SQLOperator): Correctly quote values in `Between` operator
LeandroLCD Dec 10, 2025
39c0117
Merge branch 'master' into develop
LeandroLCD Dec 10, 2025
135aed3
chore(deps): Update AGP to 8.13.2
LeandroLCD Dec 26, 2025
2eac0b0
chore(UnionQuery): Remove unused imports
LeandroLCD Dec 26, 2025
b9a220e
Merge remote-tracking branch 'origin/develop' into develop
LeandroLCD Dec 26, 2025
3b6c776
refactor(Query): Standardize LogicalOperation with a sealed interface
LeandroLCD Jan 22, 2026
d778016
refactor(Query): Rename property 'type' to 'symbol' in LogicalOperati…
LeandroLCD Jan 22, 2026
5c3ab5c
Merge branch 'master' into develop
LeandroLCD Jan 22, 2026
c2a12dc
Merge branch 'master' into develop
LeandroLCD Jan 22, 2026
d1daaee
refactor(Query): Remove unused main function and transformOperation m…
LeandroLCD Jan 22, 2026
2b1c8d7
Merge remote-tracking branch 'origin/develop' into develop
LeandroLCD Jan 22, 2026
b5a24de
fix(QuerySelect): Reset limit and orderBy in clear method
LeandroLCD Feb 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions query/src/main/java/com/blipblipcode/query/QueryDelete.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.blipblipcode.query

import com.blipblipcode.query.operator.LogicalOperation
import com.blipblipcode.query.operator.LogicalType
import com.blipblipcode.query.operator.SQLOperator

/**
Expand All @@ -14,7 +13,7 @@ import com.blipblipcode.query.operator.SQLOperator
* @property operations A map of logical operations (AND, OR, etc.) to be appended to the WHERE clause.
*/
class QueryDelete private constructor(
private var where: SQLOperator<*>?,
private var where: Pair<String, LogicalOperation>?,
private val table: String,
private val operations: LinkedHashMap<String, LogicalOperation>,
):Queryable {
Expand Down Expand Up @@ -54,7 +53,7 @@ class QueryDelete private constructor(
* @return The current `QueryDelete` instance for chaining.
*/
fun setWhere(operator: SQLOperator<*>): QueryDelete {
where = operator
where = operator.column to LogicalOperation.Where(operator)
return this
}

Expand All @@ -72,7 +71,7 @@ class QueryDelete private constructor(
override fun getSqlOperators(): List<SQLOperator<*>> {
return buildList {
require(where != null) { "A WHERE clause must be specified." }
add(where!!)
add(where!!.second.operator)
operations.values.forEach { add(it.operator) }
}
}
Expand All @@ -92,7 +91,7 @@ class QueryDelete private constructor(
*/
override fun asSql(): String {
require(where != null) { "A WHERE clause must be specified." }
return "DELETE FROM $table WHERE ${where!!.toSQLString()} ${operations.values.joinToString(" ") { it.asString() }}".trim()
return "DELETE FROM $table ${where!!.second.asString()} ${operations.values.joinToString(" ") { it.asString() }}".trim()
}

/**
Expand All @@ -103,7 +102,7 @@ class QueryDelete private constructor(
*/
override fun asSql(predicate: (SQLOperator<*>) -> Boolean): String {
require(where != null) { "A WHERE clause must be specified." }
return "DELETE FROM $table WHERE ${where!!.toSQLString()} ${operations.values.filter { predicate(it.operator) }.joinToString(" ") { it.asString() }}".trim()
return "DELETE FROM $table ${where!!.second.asString()} ${operations.values.filter { predicate(it.operator) }.joinToString(" ") { it.asString() }}".trim()
}

/**
Expand All @@ -113,7 +112,7 @@ class QueryDelete private constructor(
class QueryBuilder internal constructor(
private val table: String, private val operations: LinkedHashMap<String, LogicalOperation>
) {
private var where: SQLOperator<*>? = null
private var where: Pair<String, LogicalOperation>? = null

/**
* Clears all conditions and resets the builder.
Expand All @@ -132,7 +131,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun and(key: String, operator: SQLOperator<*>): QueryBuilder {
operations[key] = LogicalOperation(LogicalType.AND, operator)
operations[key] = LogicalOperation.And(operator)
return this
}
/**
Expand All @@ -141,7 +140,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun and(operator: SQLOperator<*>): QueryBuilder {
operations[operator.column] = LogicalOperation(LogicalType.AND, operator)
operations[operator.column] = LogicalOperation.And(operator)
return this
}

Expand All @@ -151,7 +150,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun andNot(operator: SQLOperator<*>): QueryBuilder {
operations[operator.column] = LogicalOperation(LogicalType.AND_NOT, operator)
operations[operator.column] = LogicalOperation.And(operator)
return this
}

Expand All @@ -161,7 +160,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun exists(operator: SQLOperator<*>): QueryBuilder {
operations[operator.column] = LogicalOperation(LogicalType.EXISTS, operator)
operations[operator.column] = LogicalOperation.Exists( operator)
return this
}

Expand All @@ -171,7 +170,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun not(operator: SQLOperator<*>): QueryBuilder {
operations[operator.column] = LogicalOperation(LogicalType.NOT, operator)
operations[operator.column] = LogicalOperation.Not(operator)
return this
}

Expand All @@ -182,7 +181,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun or(key: String, operator: SQLOperator<*>): QueryBuilder {
operations[key] = LogicalOperation(LogicalType.OR, operator)
operations[key] = LogicalOperation.Or(operator)
return this
}

Expand All @@ -193,7 +192,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun like(key: String, operator: SQLOperator.Like): QueryBuilder {
operations[key] = LogicalOperation(LogicalType.AND, operator)
operations[key] = LogicalOperation.And( operator)
return this
}

Expand All @@ -204,7 +203,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun all(key: String, operator: SQLOperator<*>): QueryBuilder {
operations[key] = LogicalOperation(LogicalType.ALL, operator)
operations[key] = LogicalOperation.All(operator)
return this
}

Expand All @@ -224,7 +223,7 @@ class QueryDelete private constructor(
* @return The `QueryBuilder` instance for chaining.
*/
fun where(operator: SQLOperator<*>): QueryBuilder {
where = operator
where = operator.column to LogicalOperation.Where(operator)
return this
}

Expand Down
Loading