Skip to content

Commit cce0ff6

Browse files
committed
fixes
1 parent 22985e8 commit cce0ff6

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

packages/py-moose-lib/moose_lib/data_models.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ def py_type_to_column_type(t: type, mds: list[Any]) -> Tuple[bool, list[Any], Da
221221
data_type = "IPv4"
222222
elif t is ipaddress.IPv6Address:
223223
data_type = "IPv6"
224+
elif any(md in [ # this check has to happen before t is matched against tuple/list
225+
"Point",
226+
"Ring",
227+
"LineString",
228+
"MultiLineString",
229+
"Polygon",
230+
"MultiPolygon",
231+
] for md in mds):
232+
# TODO: check the t is the tuple/array type
233+
data_type = next(md for md in mds if md in [
234+
"Point",
235+
"Ring",
236+
"LineString",
237+
"MultiLineString",
238+
"Polygon",
239+
"MultiPolygon",
240+
])
224241
elif get_origin(t) is list:
225242
inner_optional, _, inner_type = py_type_to_column_type(get_args(t)[0], [])
226243
data_type = ArrayType(element_type=inner_type, element_nullable=inner_optional)
@@ -240,23 +257,6 @@ def py_type_to_column_type(t: type, mds: list[Any]) -> Tuple[bool, list[Any], Da
240257
elif get_origin(t) is Literal and all(isinstance(arg, str) for arg in get_args(t)):
241258
data_type = "String"
242259
mds.append("LowCardinality")
243-
elif any(md in [
244-
"Point",
245-
"Ring",
246-
"LineString",
247-
"MultiLineString",
248-
"Polygon",
249-
"MultiPolygon",
250-
] for md in mds):
251-
# TODO: check the t is the tuple/array type
252-
data_type = next(md for md in mds if md in [
253-
"Point",
254-
"Ring",
255-
"LineString",
256-
"MultiLineString",
257-
"Polygon",
258-
"MultiPolygon",
259-
])
260260
elif not isclass(t):
261261
raise ValueError(f"Unknown type {t}")
262262
elif issubclass(t, BaseModel):

packages/ts-moose-lib/src/dataModels/typeConvert.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ const getGeometryMappedType = (
427427

428428
// Helper: exact tuple [number, number]
429429
const isPointTuple = (candidate: ts.Type): boolean => {
430+
if (candidate.isIntersection()) {
431+
return candidate.types.some(isPointTuple);
432+
}
430433
if (!checker.isTupleType(candidate)) return false;
431434
const tuple = candidate as TupleType;
432435
const args = tuple.typeArguments || [];
@@ -439,6 +442,9 @@ const getGeometryMappedType = (
439442
arrType: ts.Type,
440443
elementPredicate: (elType: ts.Type) => boolean,
441444
): boolean => {
445+
if (arrType.isIntersection()) {
446+
return arrType.types.some((t) => isArrayOf(t, elementPredicate));
447+
}
442448
if (!checker.isArrayType(arrType)) return false;
443449
const elementType = arrType.getNumberIndexType();
444450
if (!elementType) return false;

0 commit comments

Comments
 (0)