Skip to content

Commit

Permalink
Fix up the syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwhite4 committed Dec 6, 2018
1 parent f402bde commit b2fe00e
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions etl/js/lib/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,36 +217,43 @@ var DynamicTable = module.exports.DynamicTable = function(table) {
return reqDims.concat(restDims).concat(metrics);
};

this.getAggregationTableFields = function() {
var ret = [],
colKeys = Object.keys(this.columns).sort();
for(var col in colKeys) {
var column = this.columns[colKeys[col]];

var aggColumn = {};
for( x in column ){
aggColumn[x] = column[x];
this.getAggregationTableFields = function () {
var ret = [];
var colKeys = Object.keys(this.columns).sort();
for (let i = 0; i < colKeys.length; i++) {
if (this.columns.hasOwnProperty(colKeys[i])) {
let column = this.columns[colKeys[i]];

let aggColumn = {};
for (let x in column) {
if (column.hasOwnProperty(x)) {
aggColumn[x] = column[x];
}
}
ret.push(aggColumn);
}
ret.push(aggColumn);
}

ret.sort(dynamicSortMultiple("name"));
return ret;
},
this.getErrorInsertStatement = function(replace_, ignore, values, _version) {
if(_version === undefined || _version === null) throw Error('_version cannot be undefined or null');
//if(_id === undefined || _id === null) throw Error('_id cannot be undefined or null');
var allEntries = [];

for(var c in values) {
var column = this.columns[c];
allEntries.push(c);
}
return (replace_ ? 'replace' : ('insert' + (ignore ? ' ignore' : '' )))
+ ' into ' + this.meta.schema + '.' + this.name + '_errors (_id,' + allEntries.join(',') + ',_version)'
+ ' values (:_id, :' + allEntries.join(',:') + ',' + _version + ')';
},
}
}

ret.sort(dynamicSortMultiple('name'));
return ret;
};

this.getErrorInsertStatement = function (replace_, ignore, values, _version) {
if (_version === undefined || _version === null) {
throw Error('_version cannot be undefined or null');
}
var allEntries = [];
for (let c in values) {
if (values.hasOwnProperty(c)) {
allEntries.push(c);
}
}

return (replace_ ? 'replace' : ('insert' + (ignore ? ' ignore' : '')))
+ ' into ' + this.meta.schema + '.' + this.name + '_errors (_id,' + allEntries.join(',') + ',_version)'
+ ' values (:_id, :' + allEntries.join(',:') + ',' + _version + ')';
};
};

module.exports.sqlType = function (type, length) {
switch (type) {
Expand Down

0 comments on commit b2fe00e

Please sign in to comment.