Skip to content

Commit

Permalink
[CONJS-39] adapt geometry test to mysql that for version < 8 doesn't …
Browse files Browse the repository at this point in the history
…permit empty GeometryCollection
  • Loading branch information
rusher committed Aug 25, 2018
1 parent 944a93b commit 2c88755
Showing 1 changed file with 48 additions and 31 deletions.
79 changes: 48 additions & 31 deletions test/integration/datatype/test-geometry.js
Expand Up @@ -305,37 +305,54 @@ describe("geometry data type", () => {
it("Geometry collection format", done => {
let prefix = "";
if (!shareConn.isMariaDB() && shareConn.hasMinVersion(8, 0, 0)) prefix = "ST_";

shareConn.query("CREATE TEMPORARY TABLE gis_geometrycollection (g GEOMETRYCOLLECTION)");
shareConn
.query(
"INSERT INTO gis_geometrycollection VALUES\n" +
" (" +
prefix +
"GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),\n" +
" (" +
prefix +
"GeometryFromWKB(" +
prefix +
"AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),\n" +
" (" +
prefix +
"GeomFromText('GeometryCollection()')),\n" +
" (" +
prefix +
"GeomFromText('GeometryCollection EMPTY'))"
)
.then(() => {
return shareConn.query("SELECT * FROM gis_geometrycollection");
})
.then(rows => {
assert.deepEqual(rows, [
{ g: [{ x: 0, y: 0 }, [{ x: 0, y: 0 }, { x: 10, y: 10 }]] },
{ g: [{ x: 44, y: 6 }, [{ x: 3, y: 6 }, { x: 7, y: 9 }]] },
{ g: [] },
{ g: [] }
]);
done();
base
.createConnection()
.then(conn => {
conn.query("CREATE TEMPORARY TABLE gis_geometrycollection (g GEOMETRYCOLLECTION)");
conn
.query(
"INSERT INTO gis_geometrycollection VALUES\n" +
" (" +
prefix +
"GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),\n" +
" (" +
prefix +
"GeometryFromWKB(" +
prefix +
"AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))))" +
(!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)
? ""
: ",(" +
prefix +
"GeomFromText('GeometryCollection()')),\n" +
" (" +
prefix +
"GeomFromText('GeometryCollection EMPTY'))")
)
.then(() => {
return conn.query("SELECT * FROM gis_geometrycollection");
})
.then(rows => {
let expectedValue = [
{ g: [{ x: 0, y: 0 }, [{ x: 0, y: 0 }, { x: 10, y: 10 }]] },
{ g: [{ x: 44, y: 6 }, [{ x: 3, y: 6 }, { x: 7, y: 9 }]] },
{ g: [] },
{ g: [] }
];
if (!shareConn.isMariaDB() && !shareConn.hasMinVersion(8, 0, 0)) {
expectedValue = [
{ g: [{ x: 0, y: 0 }, [{ x: 0, y: 0 }, { x: 10, y: 10 }]] },
{ g: [{ x: 44, y: 6 }, [{ x: 3, y: 6 }, { x: 7, y: 9 }]] }
];
}
assert.deepEqual(rows, expectedValue);
conn.end();
done();
})
.catch(err => {
conn.end();
done(err);
});
})
.catch(done);
});
Expand Down

0 comments on commit 2c88755

Please sign in to comment.