Fix select statement when no resource

This commit is contained in:
adrinr 2023-02-07 12:29:58 +00:00
parent 3d917bfe22
commit 2cdc2f3fec
1 changed files with 7 additions and 2 deletions

View File

@ -90,10 +90,15 @@ function parseFilters(filters: SearchFilters | undefined): SearchFilters {
function generateSelectStatement(
json: QueryJson,
knex: Knex
): (string | Knex.Raw)[] {
): (string | Knex.Raw)[] | "*" {
const { resource, meta } = json
if (!resource) {
return "*"
}
const schema = meta?.table?.schema
return resource!.fields.map(field => {
return resource.fields.map(field => {
const fieldNames = field.split(/\./g)
const tableName = fieldNames[0]
const columnName = fieldNames[1]