Skip to content

Commit

Permalink
CASL-561 minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Amanowicz <[email protected]>
  • Loading branch information
Amaneusz committed Oct 18, 2024
1 parent 575e106 commit ad7816f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 13 additions & 3 deletions here-naksha-lib-model/src/commonMain/kotlin/naksha/model/TagMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
package naksha.model

import naksha.base.MapProxy
import naksha.model.objects.NakshaFeature
import kotlin.js.JsExport
import kotlin.js.JsName

// TODO: Document me!
// Improve me!

/**
* Map of tags persisted as (key, value) pairs where values are nullable.
* This class represents the persisted form of [TagList] / [Tag].
* It is stored as byte_array and can be accessed in PG via `naksha_tags` function.
*
* It is advised to only construct it in one of two ways:
* 1) Via [TagList]-based constructor
* 2) By deserializing byte array fetched from DB
*
* If for some reason, one would like to use it otherwise, it is advised to properly prepare tags upfront
* with use of [TagNormalizer] (that is used for example by [TagList])
*/
@JsExport
open class TagMap() : MapProxy<String, Any>(String::class, Any::class) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,10 @@ class WhereClauseBuilder(private val request: ReadFeatures) {
tagValue(tagQuery, PgType.STRING),
valuePlaceholder
)
where.append(stringEquals) // naksha_tags(tags, flags)::jsonb->>foo = $1
where.append(stringEquals)
}

is TagValueMatches -> {
/*
SELECT *
FROM read_by_tags_test
WHERE naksha_tags(tags, flags) @? '$.year ? (@ like_regex "^202\\d$")'
*/
// val regex = Regex.escape(tagQuery.regex)
val regex = tagQuery.regex
where.append("$tagsAsJsonb @?? '\$.${tagQuery.name} ? (@ like_regex \"${regex}\")'")
}
Expand Down

0 comments on commit ad7816f

Please sign in to comment.