Initial Development #1

Merged
danieljsummers merged 88 commits from v1-rc into main 2025-04-16 01:29:20 +00:00
2 changed files with 13 additions and 5 deletions
Showing only changes of commit 0b11b803cc - Show all commits

View File

@ -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

View File

@ -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() =