Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Spanner Node.js Client Library - Bigint Support for Sequences to handle INT64 datatype #2041

Open
ramgopisetty opened this issue May 6, 2024 · 0 comments
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.

Comments

@ramgopisetty
Copy link

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.

@ramgopisetty ramgopisetty added 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. labels May 6, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant