Fixing build issue caught in CI.

This commit is contained in:
mike12345567 2024-04-16 11:38:00 +01:00
parent 69ae603fa4
commit e2ca21053e
1 changed files with 7 additions and 10 deletions

View File

@ -137,18 +137,15 @@ function generateSelectStatement(
}) })
} }
function getTableName(table?: Table): string { function getTableName(table?: Table): string | undefined {
if (!table) {
throw new Error("No table name available.")
}
// SQS uses the table ID rather than the table name // SQS uses the table ID rather than the table name
if ( if (
table.sourceType === TableSourceType.INTERNAL || table?.sourceType === TableSourceType.INTERNAL ||
table.sourceId === INTERNAL_TABLE_SOURCE_ID table?.sourceId === INTERNAL_TABLE_SOURCE_ID
) { ) {
return table._id! return table?._id
} else { } else {
return table.name return table?.name
} }
} }
@ -366,7 +363,7 @@ class InternalBuilder {
const tableName = getTableName(table) const tableName = getTableName(table)
const aliases = json.tableAliases const aliases = json.tableAliases
const aliased = const aliased =
table?.name && aliases?.[tableName] ? aliases[tableName] : table?.name tableName && aliases?.[tableName] ? aliases[tableName] : table?.name
if (sort && Object.keys(sort || {}).length > 0) { if (sort && Object.keys(sort || {}).length > 0) {
for (let [key, value] of Object.entries(sort)) { for (let [key, value] of Object.entries(sort)) {
const direction = const direction =
@ -752,7 +749,7 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
if (!this._isJsonColumn(field)) { if (!this._isJsonColumn(field)) {
continue continue
} }
const aliasedTableName = aliases?.[tableName] || tableName const aliasedTableName = (tableName && aliases?.[tableName]) || tableName
const fullName = `${aliasedTableName}.${name}` const fullName = `${aliasedTableName}.${name}`
for (let row of results) { for (let row of results) {
if (typeof row[fullName] === "string") { if (typeof row[fullName] === "string") {