Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit e556c05

Browse files
authored
Merge pull request #76 from doitintl/issue-75
Fixes #75
2 parents 7f4b91d + 8219174 commit e556c05

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

dist/module.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52752,25 +52752,28 @@ function () {
5275252752
};
5275352753

5275452754
BigQueryDatasource.prototype._updateAlias = function (q, options, shiftstr) {
52755-
var index = shiftstr.search(Shifted);
52756-
var shifted = shiftstr.substr(index, shiftstr.length);
52755+
if (shiftstr !== undefined) {
52756+
var index = shiftstr.search(Shifted);
52757+
var shifted = shiftstr.substr(index, shiftstr.length);
5275752758

52758-
for (var _i = 0, _a = options.targets[0].select[0]; _i < _a.length; _i++) {
52759-
var al = _a[_i];
52759+
for (var _i = 0, _a = options.targets[0].select[0]; _i < _a.length; _i++) {
52760+
var al = _a[_i];
5276052761

52761-
if (al.type === "alias") {
52762-
q = q.replace("AS " + al.params[0], "AS " + al.params[0] + shifted);
52763-
return q;
52762+
if (al.type === "alias") {
52763+
q = q.replace("AS " + al.params[0], "AS " + al.params[0] + shifted);
52764+
return q;
52765+
}
5276452766
}
52767+
52768+
var aliasshiftted = [options.targets[0].select[0][0].params[0] + shifted];
52769+
var oldSelect = this.queryModel.buildValueColumn(options.targets[0].select[0]);
52770+
var newSelect = this.queryModel.buildValueColumn([options.targets[0].select[0][0], options.targets[0].select[0][1], {
52771+
type: "alias",
52772+
params: [aliasshiftted]
52773+
}]);
52774+
q = q.replace(oldSelect, newSelect);
5276552775
}
5276652776

52767-
var aliasshiftted = [options.targets[0].select[0][0].params[0] + shifted];
52768-
var oldSelect = this.queryModel.buildValueColumn(options.targets[0].select[0]);
52769-
var newSelect = this.queryModel.buildValueColumn([options.targets[0].select[0][0], options.targets[0].select[0][1], {
52770-
type: "alias",
52771-
params: [aliasshiftted]
52772-
}]);
52773-
q = q.replace(oldSelect, newSelect);
5277452777
return q;
5277552778
};
5277652779

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datasource.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -569,24 +569,28 @@ export class BigQueryDatasource {
569569
return data;
570570
}
571571
private _updateAlias(q, options, shiftstr) {
572-
const index = shiftstr.search(Shifted);
573-
const shifted = shiftstr.substr(index, shiftstr.length);
574-
for (const al of options.targets[0].select[0]) {
575-
if (al.type === "alias") {
576-
q = q.replace("AS " + al.params[0], "AS " + al.params[0] + shifted);
577-
return q;
572+
if (shiftstr !== undefined) {
573+
const index = shiftstr.search(Shifted);
574+
const shifted = shiftstr.substr(index, shiftstr.length);
575+
for (const al of options.targets[0].select[0]) {
576+
if (al.type === "alias") {
577+
q = q.replace("AS " + al.params[0], "AS " + al.params[0] + shifted);
578+
return q;
579+
}
578580
}
581+
const aliasshiftted = [
582+
options.targets[0].select[0][0].params[0] + shifted
583+
];
584+
const oldSelect = this.queryModel.buildValueColumn(
585+
options.targets[0].select[0]
586+
);
587+
const newSelect = this.queryModel.buildValueColumn([
588+
options.targets[0].select[0][0],
589+
options.targets[0].select[0][1],
590+
{ type: "alias", params: [aliasshiftted] }
591+
]);
592+
q = q.replace(oldSelect, newSelect);
579593
}
580-
const aliasshiftted = [options.targets[0].select[0][0].params[0] + shifted];
581-
const oldSelect = this.queryModel.buildValueColumn(
582-
options.targets[0].select[0]
583-
);
584-
const newSelect = this.queryModel.buildValueColumn([
585-
options.targets[0].select[0][0],
586-
options.targets[0].select[0][1],
587-
{ type: "alias", params: [aliasshiftted] }
588-
]);
589-
q = q.replace(oldSelect, newSelect);
590594
return q;
591595
}
592596
}

0 commit comments

Comments
 (0)