(
ctor: SpatialConstructor,
func: &ast::Function,
)
| 99 | } |
| 100 | |
| 101 | fn 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 | |
| 138 | pub(super) fn extract_table_name_from_table_with_joins( |
| 139 | table: &ast::TableWithJoins, |
no test coverage detected