Initial Development #1
@ -14,17 +14,19 @@ class Field<T> private constructor(
|
||||
val parameterName: 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
|
||||
*
|
||||
* @param paramName The parameter name to use for this field
|
||||
* @return A new `Field` with the parameter name specified
|
||||
*/
|
||||
fun withParameterName(paramName: String): Field<T> {
|
||||
if (!paramName.startsWith(':') && !paramName.startsWith('@'))
|
||||
throw DocumentException("Parameter must start with : or @ ($paramName)")
|
||||
return Field(name, comparison, paramName, qualifier)
|
||||
}
|
||||
fun withParameterName(paramName: String) =
|
||||
Field(name, comparison, paramName, qualifier)
|
||||
|
||||
/**
|
||||
* Specify a qualifier (alias) for the document table
|
||||
|
@ -530,6 +530,12 @@ class FieldTest {
|
||||
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
|
||||
@DisplayName("nameToPath creates a simple PostgreSQL SQL name")
|
||||
fun nameToPathPostgresSimpleSQL() =
|
||||
|
Loading…
x
Reference in New Issue
Block a user