Skip to content

SpannerDataReader Throws NullReferenceException For Protobuf Enum Fields #15080

@christ-salt-paymentsense

Description

Environment details

  • OS: Windows
  • .NET version: 8
  • Package name and version: Google.Cloud.Spanner.Data 5.1.0

Steps to reproduce

  1. Create a table with a column using a protobuf enum data type
syntax = "proto2";

package mycompany.enums;

enum Product {
    PRODUCT1 = 0;
    PRODUCT2 = 1;
}
  CREATE TABLE Orders (
    OrderId STRING(16) NOT NULL,
    Product mycompany.enums.Product,
  )
  PRIMARY KEY (OrderId)
  1. Reading from the table using SpannerDataReader results in a NullReferenceException calling GetValue on the Product column. The only method that seems to work for the column is GetJsonValue.

Points to note

  1. This issue was found using the spanner emulator.
  2. Comparing the metadata SpannerDataReader holds for the affected column { "name": "Product", "type": { "code": "ENUM", "protoTypeFqn": "mycompany.enums.Product" } } and the code for SpannerDbType.FromProtobufType, it looks like the code does not handle the enum type.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions