WIP on remove fields

This commit is contained in:
2025-02-22 13:30:27 -05:00
parent 07edc6ee43
commit 50de4fbf94
6 changed files with 257 additions and 3 deletions

View File

@@ -98,4 +98,23 @@ object Parameters {
throw DocumentException("Error creating query / binding parameters: ${ex.message}", ex)
}
}
/**
* Create parameters for field names to be removed from a document
*
* @param names The names of the fields to be removed
* @param parameterName The parameter name to use for the query
* @return A list of parameters to use for building the query
*/
fun fieldNames(names: Collection<String>, parameterName: String = ":name") =
when (Configuration.dialect("generate field name parameters")) {
Dialect.POSTGRESQL -> listOf(Parameter(parameterName, ParameterType.STRING, if (names.size == 1) {
names.elementAt(0)
} else {
names.joinToString(",").let { "{$it}" }
}))
Dialect.SQLITE -> names.mapIndexed { index, name ->
Parameter("$parameterName$index", ParameterType.STRING, name)
}
}
}