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

Cannot instantiate PreciseDate with JS primitive number 0 or BigInt(0) #250

Open
alvarowolfx opened this issue Apr 8, 2024 · 0 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@alvarowolfx
Copy link

When trying to instantiate the PreciseDate class with the zero epoch time, it fails.

Environment details

  • OS: macOS
  • Node.js version: 18.12.1
  • npm version: 9.4.0
  • @google-cloud/precise-date version: 4.0.0

Steps to reproduce

  1. Try to instantiate a PreciseDate with BigInt(0) or 0
  2. Throws Error: TypeError: Cannot convert a BigInt value to a number at PreciseDate

The issue is that this line

if (time && typeof time !== 'number' && !(time instanceof Date)) {
, needs to explicitly check for zero values, as zero is a valid PreciseDate.

I'll try to submit a PR later, but in the meantime a hotfix will be applyed on the BigQuery library for this issue by calling PreciseDate.parseFull + preciseDateInstance.setFulltime

Reference issue: googleapis/nodejs-bigquery#1353

@alvarowolfx alvarowolfx added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 8, 2024
@alvarowolfx alvarowolfx self-assigned this Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant