MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / spatial_constructor_to_value

Function spatial_constructor_to_value

nodedb-sql/src/planner/dml_helpers.rs:101–136  ·  view source on GitHub ↗
(
    ctor: SpatialConstructor,
    func: &ast::Function,
)

Source from the content-addressed store, hash-verified

99}
100
101fn spatial_constructor_to_value(
102 ctor: SpatialConstructor,
103 func: &ast::Function,
104) -> Result<SqlValue> {
105 let args = super::select::extract_func_args(func)?;
106 match ctor {
107 SpatialConstructor::Point => {
108 if args.len() < 2 {
109 return Err(SqlError::InvalidFunction {
110 detail: format!(
111 "{} requires 2 arguments (longitude, latitude), got {}",
112 ctor.display_name(),
113 args.len()
114 ),
115 });
116 }
117 let lon = super::select::extract_float(&args[0])?;
118 let lat = super::select::extract_float(&args[1])?;
119 Ok(SqlValue::String(format!(
120 r#"{{"type":"Point","coordinates":[{lon},{lat}]}}"#
121 )))
122 }
123 SpatialConstructor::GeomFromGeoJson => {
124 if args.is_empty() {
125 return Err(SqlError::InvalidFunction {
126 detail: format!(
127 "{} requires 1 argument (GeoJSON string)",
128 ctor.display_name()
129 ),
130 });
131 }
132 let s = super::select::extract_string_literal(&args[0])?;
133 Ok(SqlValue::String(s))
134 }
135 }
136}
137
138pub(super) fn extract_table_name_from_table_with_joins(
139 table: &ast::TableWithJoins,

Callers 1

expr_to_sql_valueFunction · 0.85

Calls 5

extract_func_argsFunction · 0.85
extract_floatFunction · 0.85
extract_string_literalFunction · 0.50
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected