Skip to content

Commit baf97e5

Browse files
committed
bigquery: drop timestamp string replacement
since https://issuetracker.google.com/issues/35905946 is fixed, bq server side now support RFC3339 format natively, hence no longer necessary to do string replacement for timestamp RFC3339 format $ node -p 'new Date().toJSON()' 2017-10-03T02:41:33.693Z $ bq query --parameter ts:TIMESTAMP:'2017-10-03T02:41:33.693Z' '#standardSQL SELECT FORMAT("%T", @ts) AS ts' Waiting on bqjob_r....... (0s) Current status: DONE +----------------------------------------+ | ts | +----------------------------------------+ | TIMESTAMP "2017-10-03 02:41:33.693+00" | +----------------------------------------+ with this change: $ node -e 'const bigquery = require("@google-cloud/bigquery")(); bigquery.query(`#standardSQL SELECT TIMESTAMP "2017-10-03T02:41:33.693Z" AS ts`) .then(([ res ]) => console.log(res))' [ { ts: { value: '2017-10-03T02:41:33.693Z' } } ] fixes googleapis#2631
1 parent a3a946e commit baf97e5

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

packages/bigquery/src/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,7 @@ BigQuery.prototype.timestamp = function(value) {
230230
return new BigQuery.timestamp(value);
231231
}
232232

233-
value = new Date(value);
234-
value = value.toJSON().replace(/^(.*)T(.*)Z$/, '$1 $2');
235-
236-
this.value = value;
233+
this.value = new Date(value).toJSON();
237234
};
238235

239236
/**

packages/bigquery/test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ describe('BigQuery', function() {
276276
describe('timestamp', function() {
277277
var INPUT_STRING = '2016-12-06T12:00:00.000Z';
278278
var INPUT_DATE = new Date(INPUT_STRING);
279-
var EXPECTED_VALUE = '2016-12-06 12:00:00.000';
279+
var EXPECTED_VALUE = '2016-12-06T12:00:00.000Z';
280280

281281
it('should expose static and instance constructors', function() {
282282
var staticT = BigQuery.timestamp(INPUT_DATE);

0 commit comments

Comments
 (0)