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

bigquery: timestamp object break the data structure #2740

Closed
knilink opened this issue Nov 10, 2017 · 1 comment
Closed

bigquery: timestamp object break the data structure #2740

knilink opened this issue Nov 10, 2017 · 1 comment
Assignees
Labels
type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@knilink
Copy link

knilink commented Nov 10, 2017

Related issue: #2479

Associating the value with the type is reasonable, but the current solution break the data structure and bring inconvenience.

I expect table.insert({time_ts: BigQuery.timestamp('2012-12-20)}) should work with schema "time_ts: TIMESTAMP" but in fact I got "This field is not a record." because what it actually send is {"time_ts":{"value":"2012-12-20"}} instead of {"time_ts":"2012-12-20"}.

The workaround I currently use is

bigquery.timestamp.prototype.toJSON = function(){return this.value;};
table.insert(JSON.parse(JSON.stringify({time_ts: BigQuery.timestamp('2012-12-20')})));

Environment details

  • OS: linux
  • Node.js version: 8.8.x
  • npm version: 5.5.1
  • google-cloud-node version: "google-cloud/bigquery@0.10.0",
@stephenplusplus stephenplusplus added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 10, 2017
@stephenplusplus stephenplusplus self-assigned this Nov 10, 2017
@stephenplusplus
Copy link
Contributor

Thanks for reporting. PR sent: #2741

@stephenplusplus stephenplusplus removed the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Nov 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants