Include * when having formulas
This commit is contained in:
parent
80dcc51923
commit
f92fcea42a
|
@ -272,12 +272,17 @@ class InternalBuilder {
|
||||||
return parts.join(".")
|
return parts.join(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
private isFullSelectStatementRequired(): boolean {
|
private isFullSelectStatementRequired(includedFields: string[]): boolean {
|
||||||
for (let column of Object.values(this.table.schema)) {
|
for (const column of Object.values(this.table.schema)) {
|
||||||
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(column)) {
|
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(column)) {
|
||||||
return true
|
return true
|
||||||
} else if (this.SPECIAL_SELECT_CASES.MSSQL_DATES(column)) {
|
} else if (this.SPECIAL_SELECT_CASES.MSSQL_DATES(column)) {
|
||||||
return true
|
return true
|
||||||
|
} else if (
|
||||||
|
column.type === FieldType.FORMULA &&
|
||||||
|
includedFields.includes(column.name)
|
||||||
|
) {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -292,11 +297,9 @@ class InternalBuilder {
|
||||||
|
|
||||||
const alias = this.getTableName(table)
|
const alias = this.getTableName(table)
|
||||||
const schema = this.table.schema
|
const schema = this.table.schema
|
||||||
if (this.isFullSelectStatementRequired()) {
|
|
||||||
return [this.knex.raw("??", [`${alias}.*`])]
|
|
||||||
}
|
|
||||||
// get just the fields for this table
|
// get just the fields for this table
|
||||||
return resource.fields
|
const tableFields = resource.fields
|
||||||
.map(field => {
|
.map(field => {
|
||||||
const parts = field.split(/\./g)
|
const parts = field.split(/\./g)
|
||||||
let table: string | undefined = undefined
|
let table: string | undefined = undefined
|
||||||
|
@ -311,7 +314,16 @@ class InternalBuilder {
|
||||||
return { table, column, field }
|
return { table, column, field }
|
||||||
})
|
})
|
||||||
.filter(({ table }) => !table || table === alias)
|
.filter(({ table }) => !table || table === alias)
|
||||||
.map(({ table, column, field }) => {
|
|
||||||
|
if (
|
||||||
|
this.isFullSelectStatementRequired(
|
||||||
|
tableFields.map(({ column }) => column)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return [this.knex.raw("??", [`${alias}.*`])]
|
||||||
|
}
|
||||||
|
|
||||||
|
return tableFields.map(({ table, column, field }) => {
|
||||||
const columnSchema = schema[column]
|
const columnSchema = schema[column]
|
||||||
|
|
||||||
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(columnSchema)) {
|
if (this.SPECIAL_SELECT_CASES.POSTGRES_MONEY(columnSchema)) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ export async function buildSqlFieldList(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isView) {
|
if (isView) {
|
||||||
Object.entries(source.schema?.[field.name].columns || {})
|
Object.entries(source.schema?.[field.name]?.columns || {})
|
||||||
.filter(([_, column]) => helpers.views.isVisible(column))
|
.filter(([_, column]) => helpers.views.isVisible(column))
|
||||||
.forEach(([field]) => viewFields.add(field))
|
.forEach(([field]) => viewFields.add(field))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue