@opengis/fastify-table 1.0.44 → 1.0.45
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/Changelog.md +4 -0
- package/package.json +1 -1
- package/table/controllers/data.js +3 -2
package/Changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -17,9 +17,10 @@ export default async function data(req) {
|
|
|
17
17
|
const {
|
|
18
18
|
table, columns, sql, cardSql, filters, form, meta,
|
|
19
19
|
} = loadTable;
|
|
20
|
-
const { pk } = await getMeta(table);
|
|
20
|
+
const { pk, columns: dbColumns } = await getMeta(table);
|
|
21
21
|
|
|
22
22
|
const cols = columns.map((el) => el.name || el).join(',');
|
|
23
|
+
const columnList = dbColumns.map((el) => el.name || el).join(',');
|
|
23
24
|
const sqlTable = sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
24
25
|
const cardSqlFiltered = params.id ? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) : [];
|
|
25
26
|
const cardSqlTable = cardSqlFiltered.length ? cardSqlFiltered.map((el, i) => ` left join lateral (select json_agg(row_to_json(q)) as ${el.name} from (${el.sql})q) ct${i} on 1=1 `).join('') || '' : '';
|
|
@@ -38,7 +39,7 @@ export default async function data(req) {
|
|
|
38
39
|
// id, query, filter
|
|
39
40
|
const [orderColumn, orderDir] = (query.order || loadTable.order || '').split(/[- ]/);
|
|
40
41
|
|
|
41
|
-
const order =
|
|
42
|
+
const order = columnList.includes(orderColumn) && orderColumn?.length ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''}` : '';
|
|
42
43
|
const state = loadTable.filterState && query.state ? loadTable.filterState[query.state]?.sql : null;
|
|
43
44
|
const custom = loadTable.filterCustom && query.custom ? loadTable.filterCustom[query.custom]?.sql : null;
|
|
44
45
|
const search = loadTable.meta?.search && query.search ? `(${loadTable.meta?.search.split(',').map(el => `${el} ilike '%${query.search}%'`).join(' or ')})` : null;
|