Driver version
7.3.0.jre-8-preview
SQL Server version
Microsoft SQL Server 2017 (RTM-CU15) (KB4498951) - 14.0.3162.1 (X64)
May 15 2019 19:14:30
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)
Client Operating System
Mac OS X
JAVA/JVM version
1.8.0
Table schema
CREATE TABLE points (location GEOGRAPHY)
Problem description
STAsBinary() returns null for single point values.
The problem is STAsBinary() always returns value of wkbNoZM field but if a Geography variable represents a single point then serializeToWkb writes to wkb field and wkbNoZM stays null. Here's relevant code in the driver
|
if (isSinglePoint || isSingleLineSegment) { |
if (isSinglePoint || isSingleLineSegment) {
wkb = buf.array();
return;
}
JDBC trace logs
Reproduction code
Geography point = Geography.parse("POINT (10 20)");
byte[] wkb = point.STAsBinary();
System.out.println(wkb);
Driver version
7.3.0.jre-8-preview
SQL Server version
Microsoft SQL Server 2017 (RTM-CU15) (KB4498951) - 14.0.3162.1 (X64)
May 15 2019 19:14:30
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)
Client Operating System
Mac OS X
JAVA/JVM version
1.8.0
Table schema
CREATE TABLE points (location GEOGRAPHY)Problem description
STAsBinary()returnsnullfor single point values.The problem is
STAsBinary()always returns value ofwkbNoZMfield but if a Geography variable represents a single point thenserializeToWkbwrites towkbfield andwkbNoZMstaysnull. Here's relevant code in the drivermssql-jdbc/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSpatialDatatype.java
Line 141 in b2ecbdc
JDBC trace logs
Reproduction code