Skip to content

[BUG] STAsBinary returns null for single point #1073

@PavelPenkov

Description

@PavelPenkov

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) {
            wkb = buf.array();
            return;
        }

JDBC trace logs

Reproduction code

        Geography point = Geography.parse("POINT (10 20)");

        byte[] wkb = point.STAsBinary();

        System.out.println(wkb);

Metadata

Metadata

Assignees

Labels

BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions