Initial Development #1
@ -14,17 +14,19 @@ class Field<T> private constructor(
|
|||||||
val parameterName: String? = null,
|
val parameterName: String? = null,
|
||||||
val qualifier: String? = null) {
|
val qualifier: String? = null) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (parameterName != null && !parameterName.startsWith(':') && !parameterName.startsWith('@'))
|
||||||
|
throw DocumentException("Parameter Name must start with : or @ ($name)")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the parameter name for the field
|
* Specify the parameter name for the field
|
||||||
*
|
*
|
||||||
* @param paramName The parameter name to use for this field
|
* @param paramName The parameter name to use for this field
|
||||||
* @return A new `Field` with the parameter name specified
|
* @return A new `Field` with the parameter name specified
|
||||||
*/
|
*/
|
||||||
fun withParameterName(paramName: String): Field<T> {
|
fun withParameterName(paramName: String) =
|
||||||
if (!paramName.startsWith(':') && !paramName.startsWith('@'))
|
Field(name, comparison, paramName, qualifier)
|
||||||
throw DocumentException("Parameter must start with : or @ ($paramName)")
|
|
||||||
return Field(name, comparison, paramName, qualifier)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a qualifier (alias) for the document table
|
* Specify a qualifier (alias) for the document table
|
||||||
|
@ -530,6 +530,12 @@ class FieldTest {
|
|||||||
assertNull(field.qualifier, "The qualifier should have been null")
|
assertNull(field.qualifier, "The qualifier should have been null")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("static constructors fail for invalid parameter name")
|
||||||
|
fun staticCtorsFailOnParamName() {
|
||||||
|
assertThrows<DocumentException> { Field.equal("a", "b", "that ain't it, Jack...") }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("nameToPath creates a simple PostgreSQL SQL name")
|
@DisplayName("nameToPath creates a simple PostgreSQL SQL name")
|
||||||
fun nameToPathPostgresSimpleSQL() =
|
fun nameToPathPostgresSimpleSQL() =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user