Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/bigquery/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ BigQuery.prototype.date = function(value) {
* precision.
*
* @example
* var datetime = bigquery.datetime('2017-01-01');
* var datetime = bigquery.datetime('2017-01-01 13:00:00');
*
* //-
* // Alternatively, provide an object.
Expand Down Expand Up @@ -1002,7 +1002,14 @@ common.paginator.extend(BigQuery, ['getDatasets', 'getJobs', 'query']);
* that a callback is omitted.
*/
common.util.promisifyAll(BigQuery, {
exclude: ['dataset', 'job']
exclude: [
'dataset',
'date',
'datetime',
'job',
'time',
'timestamp'
]
});

BigQuery.Dataset = Dataset;
Expand Down
122 changes: 76 additions & 46 deletions packages/bigquery/system-test/bigquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,22 +662,6 @@ describe('BigQuery', function() {
});
});

it('should work with dates', function(done) {
bigquery.query({
query: [
'SELECT subject',
'FROM `bigquery-public-data.github_repos.commits`',
'WHERE author.date < ?',
'LIMIT 1'
].join(' '),
params: [new Date()]
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with arrays', function(done) {
bigquery.query({
query: 'SELECT * FROM UNNEST (?)',
Expand Down Expand Up @@ -708,21 +692,54 @@ describe('BigQuery', function() {
});
});

it.skip('should work with DATETIME types', function(done) {
it('should work with TIMESTAMP types', function(done) {
bigquery.query({
query: '??',
params: []
query: [
'SELECT subject',
'FROM `bigquery-public-data.github_repos.commits`',
'WHERE author.date < ?',
'LIMIT 1'
].join(' '),
params: [new Date()]
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it.skip('should work with TIME types', function(done) {
it('should work with DATE types', function(done) {
bigquery.query({
query: '??',
params: []
query: 'SELECT ? date',
params: [
bigquery.date('2016-12-7')
]
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with DATETIME types', function(done) {
bigquery.query({
query: 'SELECT ? datetime',
params: [
bigquery.datetime('2016-12-7 14:00:00')
]
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with TIME types', function(done) {
bigquery.query({
query: 'SELECT ? time',
params: [
bigquery.time('14:00:00')
]
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
Expand Down Expand Up @@ -824,24 +841,6 @@ describe('BigQuery', function() {
});
});

it('should work with dates', function(done) {
bigquery.query({
query: [
'SELECT subject',
'FROM `bigquery-public-data.github_repos.commits`',
'WHERE author.date < @time',
'LIMIT 1'
].join(' '),
params: {
time: new Date()
}
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with arrays', function(done) {
bigquery.query({
query: 'SELECT * FROM UNNEST (@nums)',
Expand Down Expand Up @@ -874,11 +873,16 @@ describe('BigQuery', function() {
});
});

it.skip('should work with DATETIME types', function(done) {
it('should work with TIMESTAMP types', function(done) {
bigquery.query({
query: '??',
query: [
'SELECT subject',
'FROM `bigquery-public-data.github_repos.commits`',
'WHERE author.date < @time',
'LIMIT 1'
].join(' '),
params: {
datetime: {}
time: new Date()
}
}, function(err, rows) {
assert.ifError(err);
Expand All @@ -887,11 +891,37 @@ describe('BigQuery', function() {
});
});

it.skip('should work with TIME types', function(done) {
it('should work with DATE types', function(done) {
bigquery.query({
query: '??',
query: 'SELECT @date date',
params: {
date: bigquery.date('2016-12-7')
}
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with DATETIME types', function(done) {
bigquery.query({
query: 'SELECT @datetime datetime',
params: {
datetime: bigquery.datetime('2016-12-7 14:00:00')
}
}, function(err, rows) {
assert.ifError(err);
assert.equal(rows.length, 1);
done();
});
});

it('should work with TIME types', function(done) {
bigquery.query({
query: 'SELECT @time time',
params: {
time: {}
time: bigquery.time('14:00:00')
}
}, function(err, rows) {
assert.ifError(err);
Expand Down
11 changes: 9 additions & 2 deletions packages/bigquery/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ var fakeUtil = extend({}, util, {
}

promisified = true;
assert.deepEqual(options.exclude, ['dataset', 'job']);
assert.deepEqual(options.exclude, [
'dataset',
'date',
'datetime',
'job',
'time',
'timestamp'
]);
}
});

Expand Down Expand Up @@ -348,7 +355,7 @@ describe('BigQuery', function() {
assert.strictEqual(value, date);
return {
value: expectedValue
}
};
};

BigQuery.getType_ = function() {
Expand Down