Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gqlsql

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gqlsql - npm Package Compare versions

Comparing version 0.0.8 to 0.0.10

11

dist/resolver/ChildSqlQueryResolver.js

@@ -19,5 +19,11 @@ "use strict";

this.parentResolver = parentResolver;
// add tables before columns in case of qualified columns referring to tables later in the join chain
const join = (this.primaryJoin = joins[0]);
const toTable = (0, TableSpec_1.getTableName)(join.toTable);
this.addTableAlias(toTable, join.toAlias || toTable);
if (joins.length > 1) {
for (let i = 1; i < joins.length; ++i) {
this.addTable(joins[i]);
}
}
for (let i = 0; i < join.toColumns.length; ++i) {

@@ -32,7 +38,2 @@ const fromSelect = (0, _1.isFromColumns)(join)

}
if (joins.length > 1) {
for (let i = 1; i < joins.length; ++i) {
this.addTable(joins[i]);
}
}
}

@@ -39,0 +40,0 @@ addObjectField(field, join, typeNameOrFn) {

@@ -8,4 +8,8 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getKnexSelectExpression = exports.getKnexSelectColumn = exports.getTypeNameFromRow = exports.KnexSqlQueryResolver = void 0;
const assert_1 = __importDefault(require("assert"));
const snake_case_1 = require("snake-case");

@@ -93,5 +97,7 @@ const typescript_memoize_1 = require("typescript-memoize");

addSelectColumn(column, table = this.defaultTable, columnAlias) {
[column, table] = getColumnAndTable(column, table);
return this.addSelectColumnFromAlias(column, this.getTableAlias(table), columnAlias);
}
addSelectColumnFromAlias(column, tableAlias, columnAlias) {
[column, tableAlias] = getColumnAndTable(column, tableAlias);
this.checkTableAlias(tableAlias, column);

@@ -113,5 +119,7 @@ let name = columnAlias !== null && columnAlias !== void 0 ? columnAlias : column;

addCoalesceColumn(column, tables, columnAlias = column) {
(0, assert_1.default)(!isQualifiedColumn(column), 'Column must not be qualified');
return this.addCoalesceExpressionFromAliases(tables.map((table) => [this.getTableAlias(table), column]), columnAlias);
}
addCoalesceColumnFromAliases(column, tableAliases, columnAlias = column) {
(0, assert_1.default)(!isQualifiedColumn(column), 'Column must not be qualified');
return this.addCoalesceExpressionFromAliases(tableAliases.map((tableAlias) => [tableAlias, column]), columnAlias);

@@ -214,5 +222,5 @@ }

else {
baseAlias = toAlias || (aliasPrefix && aliasPrefix !== toTable ? `${aliasPrefix}_${toTable}` : toTable);
baseAlias = toAlias || toTable;
}
return this.addEquiJoinAlias(join, baseAlias);
return this.addEquiJoinAlias(join, baseAlias, aliasPrefix);
}

@@ -241,16 +249,37 @@ else {

}
addEquiJoinAlias(join, baseAlias) {
for (let alias = baseAlias, index = 1;; ++index, alias = `${baseAlias}${index}`) {
if (alias !== this.baseTableName) {
const existing = this.joinTables.get(alias);
if (!existing) {
const ext = { join: { ...join, toAlias: alias }, referenced: !!join.forced, applied: false };
this.joinTables.set(alias, ext);
return [alias, ext];
}
else if ((0, JoinSpec_1.isSameJoin)(join, existing.join)) {
return [alias, existing];
}
addEquiJoinAlias(join, baseAlias, aliasPrefix) {
const addOrMatch = (alias) => {
const existing = this.joinTables.get(alias);
if (!existing) {
const ext = { join: { ...join, toAlias: alias }, referenced: !!join.forced, applied: false };
this.joinTables.set(alias, ext);
return [alias, ext];
}
else if ((0, JoinSpec_1.isSameJoin)(join, existing.join)) {
return [alias, existing];
}
};
// Try `baseAlias` first, as long as it's not the base table name (since we
// know we need a join, which could be a self-join).
if (baseAlias !== this.baseTableName) {
const result = addOrMatch(baseAlias);
if (result) {
return result;
}
}
// If an alias prefix is specified, try `aliasPrefix_baseAlias` next.
if (aliasPrefix && aliasPrefix !== baseAlias) {
baseAlias = `${aliasPrefix}_${baseAlias}`;
const result = addOrMatch(baseAlias);
if (result) {
return result;
}
}
// Use `[aliasPrefix_]baseAliasN`, where N => 2.
for (let index = 2;; ++index) {
const result = addOrMatch(`${baseAlias}${index}`);
if (result) {
return result;
}
}
}

@@ -611,3 +640,3 @@ getJoins() {

const { table, column, alias } = select;
let expr = `${table}.${column}`;
let expr = isQualifiedColumn(column) ? column : `${table}.${column}`;
if (alias) {

@@ -659,2 +688,12 @@ expr += ` as ${alias}`;

}
function getColumnAndTable(column, defaultTable) {
const parts = column.split('.');
if (parts.length > 1) {
return [parts[1], parts[0]];
}
return [column, defaultTable];
}
function isQualifiedColumn(column) {
return column.includes('.');
}
//# sourceMappingURL=KnexSqlQueryResolver.js.map
{
"name": "gqlsql",
"version": "0.0.8",
"version": "0.0.10",
"description": "GraphQL SQL Resolver Builders",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc