Fix sql when no resource
This commit is contained in:
parent
015a91c183
commit
afa282ecbf
1 changed files with 7 additions and 2 deletions
|
@ -91,11 +91,15 @@ function generateSelectStatement(
|
||||||
json: QueryJson,
|
json: QueryJson,
|
||||||
knex: Knex,
|
knex: Knex,
|
||||||
excludeJoinColumns = false
|
excludeJoinColumns = false
|
||||||
): (string | Knex.Raw)[] {
|
): (string | Knex.Raw)[] | "*" {
|
||||||
const { resource, meta } = json
|
const { resource, meta } = json
|
||||||
const schema = meta?.table?.schema
|
const schema = meta?.table?.schema
|
||||||
|
|
||||||
return resource!.fields.reduce<(string | Knex.Raw)[]>((p, field) => {
|
if (!resource) {
|
||||||
|
return "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource.fields.reduce<(string | Knex.Raw)[]>((p, field) => {
|
||||||
const fieldNames = field.split(/\./g)
|
const fieldNames = field.split(/\./g)
|
||||||
const tableName = fieldNames[0]
|
const tableName = fieldNames[0]
|
||||||
if (
|
if (
|
||||||
|
@ -406,6 +410,7 @@ class InternalBuilder {
|
||||||
delete parsedBody[key]
|
delete parsedBody[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mysql can't use returning
|
// mysql can't use returning
|
||||||
if (opts.disableReturning) {
|
if (opts.disableReturning) {
|
||||||
return query.insert(parsedBody)
|
return query.insert(parsedBody)
|
||||||
|
|
Loading…
Reference in a new issue