WIP on query tests
This commit is contained in:
@@ -46,7 +46,7 @@ object Query {
|
||||
fun jsonContains(parameterName: String = ":criteria") =
|
||||
when (Configuration.dialect("create containment WHERE clause")) {
|
||||
Dialect.POSTGRESQL -> "data @> $parameterName"
|
||||
Dialect.SQLITE -> throw DocumentException("JSON containment is not supported")
|
||||
Dialect.SQLITE -> throw DocumentException("JSON containment is not supported")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ object Query {
|
||||
fun jsonPathMatches(parameterName: String = ":path") =
|
||||
when (Configuration.dialect("create JSON path match WHERE clause")) {
|
||||
Dialect.POSTGRESQL -> "jsonb_path_exists(data, $parameterName::jsonpath)"
|
||||
Dialect.SQLITE -> throw DocumentException("JSON path match is not supported")
|
||||
Dialect.SQLITE -> throw DocumentException("JSON path match is not supported")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ object Query {
|
||||
* Create a query on JSON fields
|
||||
*
|
||||
* @param statement The SQL statement to be run against matching fields
|
||||
* @param howMatched Whether to match any or all of the field conditions
|
||||
* @param fields The field conditions to be matched
|
||||
* @param howMatched Whether to match any or all of the field conditions (optional; default ALL)
|
||||
* @return A query addressing documents by field matching conditions
|
||||
*/
|
||||
fun byFields(statement: String, howMatched: FieldMatch, fields: Collection<Field<*>>) =
|
||||
Query.statementWhere(statement, Where.byFields(fields, howMatched))
|
||||
fun byFields(statement: String, fields: Collection<Field<*>>, howMatched: FieldMatch? = null) =
|
||||
statementWhere(statement, Where.byFields(fields, howMatched))
|
||||
|
||||
/**
|
||||
* Functions to create queries to define tables and indexes
|
||||
@@ -108,7 +108,7 @@ object Query {
|
||||
fun ensureTable(tableName: String) =
|
||||
when (Configuration.dialect("create table creation query")) {
|
||||
Dialect.POSTGRESQL -> ensureTableFor(tableName, "JSONB")
|
||||
Dialect.SQLITE -> ensureTableFor(tableName, "TEXT")
|
||||
Dialect.SQLITE -> ensureTableFor(tableName, "TEXT")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,10 +117,8 @@ object Query {
|
||||
* @param tableName The name of the table, possibly with a schema
|
||||
* @return A pair with the first item as the schema and the second as the table name
|
||||
*/
|
||||
private fun splitSchemaAndTable(tableName: String): Pair<String, String> {
|
||||
val parts = tableName.split('.')
|
||||
return if (parts.size == 1) Pair("", tableName) else Pair(parts[0], parts[1])
|
||||
}
|
||||
private fun splitSchemaAndTable(tableName: String) =
|
||||
tableName.split('.').let { if (it.size == 1) Pair("", tableName) else Pair(it[0], it[1]) }
|
||||
|
||||
/**
|
||||
* SQL statement to create an index on one or more fields in a JSON document
|
||||
|
||||
Reference in New Issue
Block a user