mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
@@ -148,18 +148,10 @@ async function parseCurrentLevel(
|
||||
|
||||
for (const child of children) {
|
||||
if (child.type === 'field') {
|
||||
const fieldKey = stripFunction(child.name);
|
||||
const fieldName = stripFunction(child.name);
|
||||
|
||||
if (columnsInCollection.includes(fieldKey) || fieldKey === '*') {
|
||||
columnsToSelectInternal.push(child.name); // maintain original name here (includes functions)
|
||||
|
||||
if (query.alias) {
|
||||
columnsToSelectInternal.push(
|
||||
...Object.entries(query.alias)
|
||||
.filter(([_key, value]) => value === child.name)
|
||||
.map(([key]) => key)
|
||||
);
|
||||
}
|
||||
if (columnsInCollection.includes(fieldName)) {
|
||||
columnsToSelectInternal.push(child.fieldKey);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -193,9 +185,7 @@ async function parseCurrentLevel(
|
||||
|
||||
const fieldNodes = columnsToSelect.map(
|
||||
(column: string) =>
|
||||
children.find(
|
||||
(childNode) => childNode.type === 'field' && (childNode.fieldKey === column || childNode.name === column)
|
||||
) ?? {
|
||||
children.find((childNode) => childNode.type === 'field' && childNode.fieldKey === column) ?? {
|
||||
type: 'field',
|
||||
name: column,
|
||||
fieldKey: column,
|
||||
@@ -209,6 +199,12 @@ function getColumnPreprocessor(knex: Knex, schema: SchemaOverview, table: string
|
||||
const helpers = getHelpers(knex);
|
||||
|
||||
return function (fieldNode: FieldNode | M2ONode): Knex.Raw<string> {
|
||||
let alias = undefined;
|
||||
|
||||
if (fieldNode.name !== fieldNode.fieldKey) {
|
||||
alias = fieldNode.fieldKey;
|
||||
}
|
||||
|
||||
let field;
|
||||
|
||||
if (fieldNode.type === 'field') {
|
||||
@@ -217,13 +213,7 @@ function getColumnPreprocessor(knex: Knex, schema: SchemaOverview, table: string
|
||||
field = schema.collections[fieldNode.relation.collection].fields[fieldNode.relation.field];
|
||||
}
|
||||
|
||||
let alias = undefined;
|
||||
|
||||
if (fieldNode.name !== fieldNode.fieldKey) {
|
||||
alias = fieldNode.fieldKey;
|
||||
}
|
||||
|
||||
if (field.type.startsWith('geometry')) {
|
||||
if (field?.type?.startsWith('geometry')) {
|
||||
return helpers.st.asText(table, field.field);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user