Fix nullable query parameters: accept omission and null for ? params

Parameters declared with `?` (e.g. `$changelogUrl: String?`) now correctly
accept omission or explicit null in JSON input instead of requiring empty
strings as a workaround. Adds `Literal::Null` variant and threads it through
parameter parsing, type-checking, and Arrow array conversion.

https://claude.ai/code/session_014oGFKL7EVg1b2cyPgt9Gne
This commit is contained in:
Claude 2026-04-13 08:43:48 +00:00
parent c5a88cacb5
commit 37b7a94eb7
No known key found for this signature in database
6 changed files with 135 additions and 13 deletions

View file

@ -160,6 +160,7 @@ impl std::fmt::Display for AggFunc {
#[derive(Debug, Clone)]
pub enum Literal {
Null,
String(String),
Integer(i64),
Float(f64),

View file

@ -1436,6 +1436,8 @@ fn resolved_type_to_field_shape(
fn literal_type(lit: &Literal) -> Result<PropType> {
match lit {
// Null is compatible with any nullable type; default to String for inference.
Literal::Null => Ok(PropType::scalar(ScalarType::String, true)),
Literal::String(_) => Ok(PropType::scalar(ScalarType::String, false)),
Literal::Integer(_) => Ok(PropType::scalar(ScalarType::I64, false)),
Literal::Float(_) => Ok(PropType::scalar(ScalarType::F64, false)),
@ -1466,6 +1468,18 @@ fn literal_type(lit: &Literal) -> Result<PropType> {
}
fn check_literal_type(lit: &Literal, expected: &PropType, prop_name: &str) -> Result<()> {
// Null is compatible with any nullable property type.
if matches!(lit, Literal::Null) {
return if expected.nullable {
Ok(())
} else {
Err(NanoError::Type(format!(
"T3: property `{}` is non-nullable but got null",
prop_name
)))
};
}
if !expected.list
&& let ScalarType::Vector(expected_dim) = expected.scalar
&& let Some(actual_dim) = numeric_vector_literal_dim(lit)