@db-auto/tables
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -22,2 +22,4 @@ "use strict"; | ||
let table = tables[path[0]]; | ||
if (table === undefined) | ||
return [`Cannot find table ${path[0]} in tables. Available tables are: ${Object.keys(tables).sort()}`]; | ||
let alias = `T${0}`; | ||
@@ -29,6 +31,6 @@ const where = [...(0, utils_1.safeArray)(wheres), ...makeWhere(id, params, alias, table)]; | ||
exports.buildPlan = buildPlan; | ||
function findLink(table, linkName) { | ||
function findLink(pathSoFar, table, linkName) { | ||
const link = table.links[linkName]; | ||
if (link === undefined) | ||
return [`Cannot find link ${linkName} in table ${table.table}. Available links are: ${Object.keys(table.links)}`]; | ||
return [`Cannot find link ${linkName} in table ${table.table} for path [${pathSoFar}]. Available links are: ${Object.keys(table.links).sort()}`]; | ||
return link; | ||
@@ -40,3 +42,4 @@ } | ||
const p = path[index]; | ||
const linkOrErrors = findLink(previousPlan.table, p); | ||
const pathSoFar = path.slice(0, index).join('.'); | ||
const linkOrErrors = findLink(pathSoFar, previousPlan.table, p); | ||
if ((0, utils_1.hasErrors)(linkOrErrors)) | ||
@@ -46,8 +49,8 @@ return linkOrErrors; | ||
const table = tables[link.table]; | ||
if (table === undefined) | ||
return [`Cannot find table ${p} in tables. Path is ${pathSoFar}. Available tables are: ${Object.keys(tables)}`]; | ||
let alias = `T${index}`; | ||
const where = makeWhere(undefined, params, alias, table); | ||
if (table === undefined) | ||
return [`Cannot find table ${p} in tables. Path is ${path.slice(0, index)}. Available tables are: ${Object.keys(tables)}`]; | ||
const plan = { table, alias, linkToPrevious: { link, linkTo: previousPlan }, where }; | ||
return buildNextStep(tables, path, params, plan, index + 1); | ||
} |
{ | ||
"name": "@db-auto/tables", | ||
"description": "", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"main": "dist/index", | ||
@@ -20,3 +20,3 @@ "types": "dist/index", | ||
"dependencies": { | ||
"@db-auto/utils": "0.0.15" | ||
"@db-auto/utils": "0.0.16" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
33021
687
+ Added@db-auto/utils@0.0.16(transitive)
- Removed@db-auto/utils@0.0.15(transitive)
Updated@db-auto/utils@0.0.16