Skip to content

Commit

Permalink
Fixes #1648
Browse files Browse the repository at this point in the history
  • Loading branch information
mtotschnig committed Feb 9, 2025
1 parent 4638319 commit 419c232
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ data class CategoryCriterion(
) : IdCriterion() {
constructor(label: String = "", vararg values: Long) : this(label, values.toList())

override val isNullable: Boolean
get() = true

@IgnoredOnParcel
override val id = R.id.FILTER_CATEGORY_COMMAND

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ sealed interface Criterion : Parcelable {
fun prettyPrint(context: Context): String
fun getSelectionArgs(queryParts: Boolean): Array<String>

val isNullable
get() = false

val displayTitle: Int
get() = when (this) {
is SimpleCriterion<*> -> displayInfo.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import kotlinx.serialization.Serializable
@SerialName("not")
data class NotCriterion(val criterion: Criterion): Criterion {
override fun getSelectionForParts(tableName: String?) =
"NOT(${criterion.getSelectionForParts(tableName)})"
addIsNullCheck("NOT(${criterion.getSelectionForParts(tableName)})")

override fun getSelectionForParents(
tableName: String?,
forExport: Boolean,
) = "NOT(${criterion.getSelectionForParents(tableName, forExport)})"
) = addIsNullCheck("NOT(${criterion.getSelectionForParents(tableName, forExport)})")

private fun addIsNullCheck(selection: String) =
if (criterion is SimpleCriterion<*> && criterion.isNullable && criterion.isNull != true)
"($selection OR ${criterion.column} IS NULL)" else selection

override fun prettyPrint(context: Context) = "¬(${criterion.prettyPrint(context)})"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ data class PayeeCriterion(
) : IdCriterion() {
constructor(label: String = "", vararg values: Long) : this(label, values.toList())

override val isNullable: Boolean
get() = true

@IgnoredOnParcel
override val id: Int = R.id.FILTER_PAYEE_COMMAND
@IgnoredOnParcel
Expand Down

0 comments on commit 419c232

Please sign in to comment.