diff --git a/azure-kusto-data/package-lock.json b/azure-kusto-data/package-lock.json index 576b68dc..63739247 100644 --- a/azure-kusto-data/package-lock.json +++ b/azure-kusto-data/package-lock.json @@ -1,6 +1,6 @@ { "name": "azure-kusto-data", - "version": "0.1.0", + "version": "0.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/azure-kusto-data/package.json b/azure-kusto-data/package.json index c637c5d6..5714fe36 100644 --- a/azure-kusto-data/package.json +++ b/azure-kusto-data/package.json @@ -1,6 +1,6 @@ { "name": "azure-kusto-data", - "version": "0.1.2", + "version": "0.1.4", "description": "", "main": "index.js", "engines": { diff --git a/azure-kusto-data/source/client.js b/azure-kusto-data/source/client.js index a27e2f09..96980f69 100644 --- a/azure-kusto-data/source/client.js +++ b/azure-kusto-data/source/client.js @@ -49,7 +49,7 @@ module.exports = class KustoClient { "Content-Type": "application/json; charset=utf-8", "Fed": "True", "x-ms-client-version": `Kusto.Node.Client:${pkg.version}`, - "x-ms-client-request-id": `KPC.execute;${uuidv4()}`, + "x-ms-client-request-id": `KNC.execute;${uuidv4()}`, }; const { timeout } = options || {}; diff --git a/azure-kusto-data/source/models.js b/azure-kusto-data/source/models.js index d6ebf141..d7d59b16 100644 --- a/azure-kusto-data/source/models.js +++ b/azure-kusto-data/source/models.js @@ -18,7 +18,7 @@ const ValueParser = { class KustoResultRow { constructor(columns, row) { - this.columns = columns.sort((a, b) => a.ordianl - b.ordianl); + this.columns = columns.sort((a, b) => a.ordinal - b.ordinal); this.raw = row; for (let col of this.columns) { @@ -56,11 +56,11 @@ class KustoResultRow { module.exports.KustoResultRow = KustoResultRow; class KustoResultColumn { - constructor(columnObj, ordianl) { + constructor(columnObj, ordinal) { this.name = columnObj.ColumnName; // TODO: should validate type? should coarse value to type? this.type = columnObj.ColumnType || columnObj.DateType; - this.ordinal = ordianl; + this.ordinal = ordinal; } } diff --git a/azure-kusto-data/test/modelsTest.js b/azure-kusto-data/test/modelsTest.js index 4497e283..3f35859f 100644 --- a/azure-kusto-data/test/modelsTest.js +++ b/azure-kusto-data/test/modelsTest.js @@ -51,6 +51,46 @@ describe("KustoResultRow", function () { assert.equal(actual.columns.length, inputColumns.length); }); + it("column ordinal affects order", function () { + const inputValues = [ + "2016-06-06T15:35:00Z", + "foo", + 101, + 3.14, + false, + 3493235670000 + ]; + + const reverseOrderColumns = rawColumns.slice().reverse(); + const actual = new KustoResultRow( + reverseOrderColumns.map((c, i) => new KustoResultColumn(c, rawColumns.length - i - 1)), + inputValues + ); + + let asJson = actual.toJson(); + let expectedValues = [ + moment(inputValues[0]), + inputValues[1], + inputValues[2], + inputValues[3], + inputValues[4], + moment(inputValues[5]), + ]; + + for (let index = 0; index < inputColumns.length; index++) { + let actual = asJson[inputColumns[index].name]; + if (inputColumns[index].type === "timespan") { + assert.equal(Number(actual), expectedValues[index]); + } + else if (typeof(actual) == "object") { + assert.equal(actual.toString(), expectedValues[index].toString()); + } else { + assert.equal(actual, expectedValues[index]); + } + } + + }); + it("mismatching data - less data than columns", function () { const inputValues = [ "2016-06-06T15:35:00Z", diff --git a/azure-kusto-ingest/package.json b/azure-kusto-ingest/package.json index 1a0537c2..eb81d720 100644 --- a/azure-kusto-ingest/package.json +++ b/azure-kusto-ingest/package.json @@ -1,6 +1,6 @@ { "name": "azure-kusto-ingest", - "version": "0.1.2", + "version": "0.1.4", "description": "", "main": "./index.js", "engines": {