Feature Request: Spanner Node.js Client Library - Bigint Support for Sequences to handle INT64 datatype #2041
Labels
api: spanner
Issues related to the googleapis/nodejs-spanner API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Feature Request: Spanner Node.js Client Library - Bigint Support for Sequences to handle INT64 datatype
Is your feature request related to a problem? Please describe.
Yes.Currently, the Spanner Node.js client libraries do not have native support for the Bigint data type when interacting with sequences. This is problematic because sequences in Spanner are designed to generate monotonically increasing 64-bit integers, which are best represented as BigINT in JavaScript.
The lack of Bigint support forces developers to resort to workarounds like:
String conversion: fetching the sequence value as a string and then manually converting it to a Bigint in application code. This is cumbersome and error-prone.
Number conversion with potential loss of precision: Using JavaScript's Number type, which can lead to incorrect results if the sequence value exceeds the maximum safe integer value (2^53 - 1).
Describe the solution you'd like
I would like the Spanner Node.js client libraries to be updated to natively support Bigints when working with sequences. Specifically:
read()/readRow() methods: When a column containing a sequence value is fetched, the client library should automatically return it as a Bigint.
Parameter binding: When providing a Bigint value as a parameter for an INSERT or UPDATE statement that affects a sequence, the library should handle the conversion to the appropriate Spanner type seamlessly.
Describe alternatives you've considered
String conversion or using wrap_around() for all numbers. Which is cumbersome.
Additional context
Use case: Sequences are commonly used in Spanner for generating unique identifiers for records. This feature is particularly important for applications that rely heavily on sequences and deal with large datasets where the sequence values could exceed the safe integer limit.
Impact: Adding native Bigint support would significantly improve the developer experience by simplifying interactions with sequences and eliminating the need for workarounds. It would also ensure the accuracy and reliability of sequence handling in Node.js applications using Spanner.
The text was updated successfully, but these errors were encountered: