Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mavenPassword=YourPassword
# here-naksha-lib-psql/src/commonMain/kotlin/naksha/psql/LibPsql.kt (adminVersion property)
# Warning: Only update LibPsql version, if there is a change in SQL functions!
# The reason is, that this version is encoded in the database, and when updated, forced an upgrade!
version=3.0.0-beta.36
version=3.0.0-beta.37

org.gradle.jvmargs=-Xmx12g
kotlin.code.style=official
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ servers:
info:
title: "Naskha Hub-API"
description: "Naksha Hub-API is a REST API to provide simple access to geo data."
version: "3.0.0-beta.36"
version: "3.0.0-beta.37"

security:
- AccessToken: [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NakshaVersion(
* The current version as string to constant usage cases.
* @since 3.0
*/
const val CURRENT = "3.0.0-beta.36"
const val CURRENT = "3.0.0-beta.37"
// WARNING: Do not update this property manually, it is automatically modified when building!
// Edit version only in `gradle.properties` file, which is used as well to create artifacts!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,10 @@ internal class PgQueryWhereBuilder(private val request: ReadFeatures) {
if(containsOnlyTagExists(tagQuery)){
// for tags without values we can utilize top-level-key based '?|' operand
// https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
val tagNames = tagQuery.filterIsInstance<TagExists>().map { it.name }
resolveTagNamesArrayOperation(
jsonbOperator = "jsonb_exists_any", // equivalent of '?|'
tagNames = (tagQuery as ListProxy<TagExists>).mapNotNull { it?.name }
jsonbOperator = "?|", // 'jsonb_exists_any' is equivalent but will not hit the GIN index
tagNames = tagNames
)
} else {
or(tagQuery.filterNotNull(), this::whereNestedTags)
Expand All @@ -346,9 +347,10 @@ internal class PgQueryWhereBuilder(private val request: ReadFeatures) {
if(containsOnlyTagExists(tagQuery)){
// for tags without values we can utilize top-level-key based '?&' operand
// https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
val tagNames = tagQuery.filterIsInstance<TagExists>().map { it.name }
resolveTagNamesArrayOperation(
jsonbOperator = "jsonb_exists_all", // equivalent of '?&'
tagNames = (tagQuery as ListProxy<TagExists>).mapNotNull { it?.name }
jsonbOperator = "?&", // 'jsonb_exists_all' is equivalent but MIGHT not hit the GIN index
tagNames = tagNames
)
} else {
and(tagQuery.filterNotNull(), this::whereNestedTags)
Expand All @@ -359,12 +361,12 @@ internal class PgQueryWhereBuilder(private val request: ReadFeatures) {
}

private fun containsOnlyTagExists(container: ListProxy<ITagQuery>): Boolean =
container.all { it is TagExists }
container.all { it == null || it is TagExists }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed? The name of the function let me assume, that null should not be a valid TagExists

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially assumed so as well, but apparently ListProxy<E : Any> : MutableList<E?>, the underlying E? means it can actually store null underneath.


private fun resolveTagNamesArrayOperation(jsonbOperator: String, tagNames: List<String>) {
val tagKeysArray = tagNames.toTypedArray()
val tagKeysPlaceholder = placeholderForArg(tagKeysArray, PgType.STRING_ARRAY)
where.append("$jsonbOperator($tagsAsJsonb, $tagKeysPlaceholder)")
where.append("$tagsAsJsonb ?$jsonbOperator $tagKeysPlaceholder")
}

private fun resolveSingleTagQuery(tagQuery: TagQuery) {
Expand Down
Loading