Merge 'Add support for json_object function' from Jorge Hermo

Relates to #127.  This PR is still in draft and I have a few left things
to do (tests, improve implementation), just opening it so anyone can
track this work meanwhile.

Closes #664
This commit is contained in:
Pekka Enberg
2025-01-20 09:36:56 +02:00
6 changed files with 283 additions and 6 deletions

View File

@@ -76,6 +76,7 @@ pub enum JsonFunc {
JsonArrowExtract,
JsonArrowShiftExtract,
JsonExtract,
JsonObject,
JsonType,
JsonErrorPosition,
}
@@ -93,6 +94,7 @@ impl Display for JsonFunc {
Self::JsonArrayLength => "json_array_length".to_string(),
Self::JsonArrowExtract => "->".to_string(),
Self::JsonArrowShiftExtract => "->>".to_string(),
Self::JsonObject => "json_object".to_string(),
Self::JsonType => "json_type".to_string(),
Self::JsonErrorPosition => "json_error_position".to_string(),
}
@@ -510,6 +512,8 @@ impl Func {
#[cfg(feature = "json")]
"json_extract" => Ok(Func::Json(JsonFunc::JsonExtract)),
#[cfg(feature = "json")]
"json_object" => Ok(Func::Json(JsonFunc::JsonObject)),
#[cfg(feature = "json")]
"json_type" => Ok(Func::Json(JsonFunc::JsonType)),
#[cfg(feature = "json")]
"json_error_position" => Ok(Self::Json(JsonFunc::JsonErrorPosition)),