Skip to content

Commit

Permalink
Merge branch 'pr/805-not-tn-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
nevenz committed May 13, 2021
2 parents 06fcfa1 + 9839a41 commit 4425eb5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ class QueryTest(private val param: Parameter) : OrgzlyTest() {
expectedSqlSelection = "((COALESCE(tags, '') LIKE ? OR COALESCE(inherited_tags, '') LIKE ?))",
expectedSelectionArgs = listOf("%tag%", "%tag%")
),
Parameter(
queryString = ".tn.tag",
expectedQueryString = ".tn.tag",
expectedSqlSelection = "(NOT((COALESCE(tags, '') LIKE ?)))",
expectedSelectionArgs = listOf("%tag%")
),
Parameter(
queryString = "i.todo (b.\"book(1) name\" or b.book2)",
expectedQueryString = "i.todo (b.\"book(1) name\" or b.book2)",
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/orgzly/android/query/Condition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sealed class Condition {
data class HasSetPriority(val priority: String, val not: Boolean = false) : Condition()

data class HasTag(val tag: String, val not: Boolean = false) : Condition()
data class HasOwnTag(val tag: String) : Condition()
data class HasOwnTag(val tag: String, val not: Boolean = false) : Condition()

data class Event(val interval: QueryInterval, val relation: Relation) : Condition()
data class Scheduled(val interval: QueryInterval, val relation: Relation) : Condition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class SqliteQueryBuilder(val context: Context) {

is Condition.HasOwnTag -> {
arguments.add("%${expr.tag}%")
"tags LIKE ?"
not(expr.not, "(COALESCE(tags, '') LIKE ?)")
}

is Condition.Event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ open class BasicQueryParser : QueryParser() {
Condition.HasTag(unQuote(match.groupValues[2]), match.groupValues[1].isNotEmpty())
},

ConditionMatch("""^own-tag:(.+)""") { match ->
Condition.HasOwnTag(unQuote(match.groupValues[1]))
ConditionMatch("""^(-)?own-tag:(.+)""") { match ->
Condition.HasOwnTag(unQuote(match.groupValues[2]), match.groupValues[1].isNotEmpty())
},

ConditionMatch("""^(scheduled|deadline|closed|created):(?:(!=|<|<=|>|>=))?(.+)""") { match ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class DottedQueryBuilder {
is Condition.HasSetPriority -> "${dot(expr.not)}ps.${expr.priority}"

is Condition.HasTag -> "${dot(expr.not)}t.${expr.tag}"
is Condition.HasOwnTag -> "tn.${expr.tag}"
is Condition.HasOwnTag -> "${dot(expr.not)}tn.${expr.tag}"

is Condition.Event -> {
val rel = expr.relation.toString().toLowerCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ open class DottedQueryParser : QueryParser() {
Condition.HasTag(unQuote(match.groupValues[2]), match.groupValues[1].isNotEmpty())
},

ConditionMatch("""^tn\.(.+)""") { match ->
Condition.HasOwnTag(unQuote(match.groupValues[1]))
ConditionMatch("""^(\.)?tn\.(.+)""") { match ->
Condition.HasOwnTag(unQuote(match.groupValues[2]), match.groupValues[1].isNotEmpty())
},

ConditionMatch("""^(e|s|d|c|cr)(?:\.(eq|ne|lt|le|gt|ge))?\.(.+)""") { match ->
Expand Down

0 comments on commit 4425eb5

Please sign in to comment.