@opengis/fastify-table 1.1.144 → 1.1.146
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
|
@@ -10,12 +10,12 @@ const sqls = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default async function getSelect(name, pg = pgClients.client) {
|
|
13
|
-
if (loadCls[name]) return loadCls[name];
|
|
13
|
+
if (loadCls[name] && false) return loadCls[name];
|
|
14
14
|
|
|
15
15
|
const clsDataGIT = await getTemplate(['cls', 'select'], name);
|
|
16
16
|
const { type } = !clsDataGIT && pg.pk?.['admin.user_cls'] ? await pg.query('select type from admin.user_cls where parent is null and name=$1 union all select type from admin.cls where parent is null and name=$1 limit 1', [name]).then(el => el.rows?.[0] || {}) : {};
|
|
17
17
|
const q = !clsDataGIT && type && ['sql', 'json'].includes(type) ? sqls[type] : undefined;
|
|
18
|
-
const clsDataDB = q ? await pg.query(q, [name]).then(el => el.rows?.
|
|
18
|
+
const clsDataDB = q ? await pg.query(q, [name]).then(el => el.rows?.find(el => el?.data)?.data) : undefined;
|
|
19
19
|
const clsData = clsDataGIT || clsDataDB;
|
|
20
20
|
if (!clsData) return null;
|
|
21
21
|
|
|
@@ -28,7 +28,9 @@ export default async function suggest(req) {
|
|
|
28
28
|
if (table && !pg1.pk[body?.table || table]) {
|
|
29
29
|
return { status: 400, message: 'param name is invalid: 1' };
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
const tableMeta = await getMeta({ table: body?.table || table });
|
|
33
|
+
const columnExists = (body?.columns || tableMeta?.columns)?.find((col) => col?.name === column);
|
|
32
34
|
|
|
33
35
|
if (table && (!column || !columnExists)) {
|
|
34
36
|
return { status: 400, message: 'param name is invalid: 2' };
|
|
@@ -121,7 +123,7 @@ export default async function suggest(req) {
|
|
|
121
123
|
// return meta;
|
|
122
124
|
|
|
123
125
|
const val = query.val ? ` ${meta.pk}=any('{${query.val.replace(/'/g, "''")}}')` : '';
|
|
124
|
-
const where = [search, val, `${meta.pk} is not null`].filter((el) => el).join(' and ') || 'true';
|
|
126
|
+
const where = [search, val, meta.pk ? `${meta.pk} is not null` : null].filter((el) => el).join(' and ') || 'true';
|
|
125
127
|
|
|
126
128
|
const loadTable = await getTemplate('table', query.token);
|
|
127
129
|
const { columns = [] } = await getMeta({ table: loadTable?.table || query.token });
|