From b7ba0f7aab1465b82397865814f78328e69df9dd Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Mon, 23 Sep 2024 22:21:24 +0530 Subject: [PATCH] follow TS convention --- package.json | 1 + src/connector/execution.ts | 15 ++++++--------- src/connector/sql/sqlGeneration.ts | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ce75013..0cb22be 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ }, "scripts": { "test": "mocha", + "ndc-test": "node script/test-setup.js", "build": "rimraf ./build && tsc", "start": "npm run build && ts-node ./src/index.ts", diff --git a/src/connector/execution.ts b/src/connector/execution.ts index c084660..cae1dec 100644 --- a/src/connector/execution.ts +++ b/src/connector/execution.ts @@ -304,7 +304,7 @@ function parseQueryRequest( let requestedFields: sql.SelectColumns = {}; - if (collectionDefinition === undefined) + if (!collectionDefinition) throw new sdk.BadRequest( `Couldn't find collection '${collection}' in the schema.`, ); @@ -322,7 +322,7 @@ function parseQueryRequest( const collectionObjectType = collectionsSchema.objectTypes[collectionObjectBaseType]; - if (collectionObjectType === undefined) + if (!collectionObjectType) throw new sdk.InternalServerError( `Couldn't find the schema of the object type: '${collectionObjectBaseType}'`, ); @@ -419,8 +419,8 @@ function parseQueryRequest( selectAsValue: false, }; - if (queryRequest.query.limit != null) { - if (queryRequest.query.offset != null) { + if (queryRequest.query.limit) { + if (queryRequest.query.offset) { sqlGenCtx.offset = queryRequest.query.offset; } else { // The Azure Cosmos DB for NoSQL SQL syntax always requires an @@ -431,10 +431,7 @@ function parseQueryRequest( sqlGenCtx.limit = queryRequest.query.limit; } - if ( - queryRequest.query.order_by != null && - queryRequest.query.order_by != undefined - ) { + if (queryRequest.query.order_by) { validateOrderBy(queryRequest.query.order_by, collectionObjectType); sqlGenCtx.orderBy = queryRequest.query.order_by; } @@ -464,7 +461,7 @@ export async function executeQuery( const collectionDefinition: schema.CollectionDefinition = collectionsSchema.collections[collection]; - if (collectionDefinition === undefined) + if (!collectionDefinition) throw new sdk.BadRequest( `Couldn't find collection '${collection}' in the schema.`, ); diff --git a/src/connector/sql/sqlGeneration.ts b/src/connector/sql/sqlGeneration.ts index 154d639..3c40701 100644 --- a/src/connector/sql/sqlGeneration.ts +++ b/src/connector/sql/sqlGeneration.ts @@ -384,7 +384,7 @@ export function getScalarType(column: Column): string { return getNestedScalarType(column.nestedField); } - if (column.type === undefined) { + if (!column.type) { throw new sdk.BadRequest(`Couldn't find type of column: ${column.name}`); } else { switch (column.type.type) {