@opengis/fastify-table 1.2.74 → 1.2.76
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
|
@@ -44,7 +44,7 @@ export default async function getFilterSQL({
|
|
|
44
44
|
// console.log('extra getFilterSQL', extraDataTable, pg.pk?.[extraDataTable]);
|
|
45
45
|
|
|
46
46
|
// check sql inline fields count
|
|
47
|
-
if (!checkInline[body?.table] && body?.sql?.length
|
|
47
|
+
if (body?.table && !checkInline[body?.table] && body?.sql?.length) {
|
|
48
48
|
const filterSql = body.sql.filter(el => !el?.disabled && (el.inline ?? true));
|
|
49
49
|
const sqlTable = filterSql.map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
50
50
|
const d = await Promise.all(filterSql.map((el, i) => pg.query(`select ${el.name || `t${i}`}.* from(select * from ${body.table})t ${sqlTable} limit 0`).then(el => el.fields)))
|
|
@@ -63,7 +63,7 @@ export default async function getFilterSQL({
|
|
|
63
63
|
.map((el, i) => ` left join lateral (${el.sql.replace('{{uid}}', uid)}) ${el.name || `t${i}`} on 1=1 `)
|
|
64
64
|
.join('')
|
|
65
65
|
: null;
|
|
66
|
-
const sqlInline = body
|
|
66
|
+
const sqlInline = body?.sql?.filter?.(el => el.inline).map(el => `,(${el.sql})`).join('');
|
|
67
67
|
|
|
68
68
|
const fieldQuery = `select * ${extraSqlColumns || ''} ${sqlInline || ''} from ${body?.table || table} t ${sqlTable || ''} limit 0`;
|
|
69
69
|
const { fields = [] } = await pg.query(fieldQuery);
|
|
@@ -78,7 +78,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
78
78
|
const cardSqlFiltered = hookData?.id || params.id ? (cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) || []) : [];
|
|
79
79
|
const cardSqlTable = cardSqlFiltered.length ? cardSqlFiltered.map((el, i) => ` left join lateral (${el.sql.replace('{{uid}}', uid)}) ct${i} on 1=1 `).join('\n') || '' : '';
|
|
80
80
|
|
|
81
|
-
const sqlInline = loadTable
|
|
81
|
+
const sqlInline = loadTable?.sql?.filter?.(el => el.inline)?.map(el => `,(${el.sql})`)?.join('') || '';
|
|
82
82
|
const { fields = [] } = pg.queryCache ? await pg.queryCache(`select * ${sqlInline} from ${table} t ${sqlTable} ${cardSqlTable} limit 0`) : {};
|
|
83
83
|
const dbColumnsTable = fields.map(el => el.name);
|
|
84
84
|
const cols = columns.filter((el) => el.name !== 'geom' && dbColumnsTable.includes(el.name)).map((el) => el.name || el).join(',');
|
|
@@ -102,7 +102,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
102
102
|
const checkFilter = [query.filter, query.search, query.state, query.custom].filter((el) => el).length;
|
|
103
103
|
const fData = checkFilter ? await getFilterSQL({
|
|
104
104
|
pg,
|
|
105
|
-
table: params.table,
|
|
105
|
+
table: loadTable ? params.table : table,
|
|
106
106
|
filter: query.filter,
|
|
107
107
|
search: query.search,
|
|
108
108
|
state: query.state,
|