@opengis/fastify-table 1.2.77 → 1.2.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -134,9 +134,9 @@ export default async function suggest(req) {
|
|
|
134
134
|
|
|
135
135
|
const { columns = [] } = await getMeta({ pg: pg1, table: tableName1 });
|
|
136
136
|
|
|
137
|
-
const filterColumn = query.column ? columns.find(el => el.name === query.column)
|
|
138
|
-
const filter = query.token && pg.pk?.[loadTable?.table || query.token] && filterColumn
|
|
139
|
-
? `id in (select ${filterColumn} from ${(loadTable?.table || query.token).replace(/'/g, "''")})`
|
|
137
|
+
const { name: filterColumn, dataTypeID } = query.column ? (columns.find(el => el.name === query.column) || {}) : {};
|
|
138
|
+
const filter = query.token && pg.pk?.[loadTable?.table || query.token] && filterColumn && dataTypeID
|
|
139
|
+
? `id in (select ${pg.pgType[dataTypeID]?.includes('[]') ? `unnest(${filterColumn})` : filterColumn} from ${(loadTable?.table || query.token).replace(/'/g, "''")})`
|
|
140
140
|
: 'true';
|
|
141
141
|
|
|
142
142
|
const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} order by 2) select * from c where ${filter} limit ${Math.min(query.limit || meta.limit || limit, limit)}`.replace(/{{uid}}/g, user?.uid || '0');
|
|
@@ -149,7 +149,7 @@ export default async function suggest(req) {
|
|
|
149
149
|
const { rows: dataNew } = await pg.query(sqlSuggest, query.key ? [`${query.key.toLowerCase()}`] : []);
|
|
150
150
|
// const { rows: dataNew1 } = dataNew.length < limit ? await pg.query(sqlSuggest, query.key ? [`${query.key}`] : []) : {};
|
|
151
151
|
const ids = dataNew.map((el) => el.id);
|
|
152
|
-
const data = dataNew.concat((/* dataNew1 || */[]).filter(
|
|
152
|
+
const data = dataNew.concat((/* dataNew1 || */[]).filter(el => !ids?.includes(el.id))).filter(el => el.text);
|
|
153
153
|
|
|
154
154
|
if (query.sel) {
|
|
155
155
|
const clsData = await getSelectVal({
|