@opengis/fastify-table 1.2.53 → 1.2.54
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
|
@@ -11,13 +11,14 @@ export default async function filterAPI(req) {
|
|
|
11
11
|
if (!loadTable) { return { status: 404, message: 'not found' }; }
|
|
12
12
|
|
|
13
13
|
const sqlTable = loadTable.sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql.replace('{{uid}}', user?.uid)}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
14
|
-
const { fields: columns } = await pg.query(`select * from ${loadTable.table} t ${sqlTable} limit 0`);
|
|
14
|
+
const { fields: columns = [] } = await pg.query(`select * from ${loadTable.table} t ${sqlTable} limit 0`);
|
|
15
|
+
const { fields = [] } = await pg.query(`select * from ${loadTable.table} t limit 0`);
|
|
15
16
|
|
|
16
17
|
const {
|
|
17
18
|
filter, custom, state, search,
|
|
18
19
|
} = query;
|
|
19
20
|
|
|
20
|
-
const { extra } = loadTable?.form ? await getTemplate('form', loadTable?.form) : {};
|
|
21
|
+
const { extra } = loadTable?.form ? await getTemplate('form', loadTable?.form) || {} : {};
|
|
21
22
|
|
|
22
23
|
const { optimizedSQL = `select * from ${loadTable.table}` } = loadTable?.sql || filter || custom || state || search || extra ? await getFilterSQL({
|
|
23
24
|
pg,
|
|
@@ -86,7 +87,7 @@ export default async function filterAPI(req) {
|
|
|
86
87
|
?.join(' ') || '';
|
|
87
88
|
|
|
88
89
|
// percentile_cont - alternative
|
|
89
|
-
await Promise.all(filters.filter((el) => el.name && el.type === 'Range' &&
|
|
90
|
+
await Promise.all(filters.filter((el) => el.name && el.type === 'Range' && fields?.find?.((item) => item?.name === el.name)).map(async (el) => {
|
|
90
91
|
const data = await pg.queryCache(`select array[
|
|
91
92
|
min(${el.name}),
|
|
92
93
|
percentile_disc(0.25) within group (order by ${el.name}),
|