Skip to content

Commit f8f095b

Browse files
committed
fix postgres substring polygon
1 parent 1028065 commit f8f095b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,14 +1921,14 @@ export class PostgresStorageAdapter implements StorageAdapter {
19211921
};
19221922
}
19231923
if (object[fieldName] && schema.fields[fieldName].type === 'Polygon') {
1924-
let coords = object[fieldName];
1925-
coords = coords.substr(2, coords.length - 4).split('),(');
1926-
coords = coords.map(point => {
1924+
let coords = new String(object[fieldName]);
1925+
coords = coords.substring(2, coords.length - 2).split('),(');
1926+
const updatedCoords = coords.map(point => {
19271927
return [parseFloat(point.split(',')[1]), parseFloat(point.split(',')[0])];
19281928
});
19291929
object[fieldName] = {
19301930
__type: 'Polygon',
1931-
coordinates: coords,
1931+
coordinates: updatedCoords,
19321932
};
19331933
}
19341934
if (object[fieldName] && schema.fields[fieldName].type === 'File') {

0 commit comments

Comments
 (0)