fix(xugu): preserve spatial SRIDs in exports

This commit is contained in:
Elias authored and GitHub committed 2026-08-25 15:15:41 +08:00
1 parent 343d006300
commit e9fea304ba
13 files changed
+669 -32

No files matched your search

@@ -29,6 +29,29 @@ function context(): PreviewActionContext {
}
describe("buildGeometryMapFeatureCollection", () => {
it("treats GEOGRAPHY columns as map-preview layers and preserves SRID metadata", () => {
const ctx = context();
ctx.result.column_types = ["GEOGRAPHY", "text"];
ctx.result.columns = ["location", "name"];
ctx.result.rows = [["SRID=4326;POINT(116.397 39.908)", "wgs84"]];
ctx.result.spatial_columns = [{ column_index: 0, srid: 4326 }];
ctx.result.spatial_values = [[4326, null]];
ctx.displayRowRefs = [{ id: 1, sourceIndex: 0, isNew: false }];
expect(hasGeometryMapPreviewColumns(ctx.result)).toBe(true);
expect(buildGeometryMapFeatureCollection(ctx)).toEqual({
type: "FeatureCollection",
detectedSrid: 4326,
features: [
{
type: "Feature",
geometry: { type: "Point", coordinates: [116.397, 39.908] },
properties: { _column: "location", _row: 0, _srid: 4326, name: "wgs84" },
},
],
});
});
it("checks preview availability from column metadata without parsing result rows", () => {
const result = context().result;
expect(hasGeometryMapPreviewColumns(result)).toBe(true);
@@ -18,6 +18,8 @@ export interface ExportedTableSql {
columns: string[];
columnTypes?: Array<string | null | undefined>;
columnExtras?: Array<string | null | undefined>;
spatialColumns?: QueryResult["spatial_columns"];
spatialValues?: QueryResult["spatial_values"];
rows: QueryResult["rows"];
truncated?: boolean;
}
@@ -41,6 +43,8 @@ export interface BuildExportInsertStatementsOptions {
columns: string[];
columnTypes?: Array<string | null | undefined>;
columnExtras?: Array<string | null | undefined>;
spatialColumns?: QueryResult["spatial_columns"];
spatialValues?: QueryResult["spatial_values"];
rows: QueryResult["rows"];
batchSize?: number;
}
+3 -1
View File
@@ -1,4 +1,4 @@
import type { DatabaseType } from "@/types/database";
import type { DatabaseType, QueryResult } from "@/types/database";
import * as api from "@/lib/backend/api";
export type ExportCellValue = string | number | boolean | null;
@@ -35,6 +35,8 @@ export interface FormatSqlInsertOptions {
qualifiedTableName?: string;
columns: string[];
columnTypes?: Array<string | null | undefined>;
spatialColumns?: QueryResult["spatial_columns"];
spatialValues?: QueryResult["spatial_values"];
rows: ExportCellValue[][];
}