@opengis/fastify-table 1.3.47 → 1.3.49
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/index.js
CHANGED
|
@@ -59,7 +59,7 @@ async function plugin(fastify, opt) {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// core migrations (second argument for core only)
|
|
62
|
-
|
|
62
|
+
execMigrations(path.join(cwd, 'server/migrations'), true).catch(err => console.log(err));
|
|
63
63
|
|
|
64
64
|
// core templates && cls
|
|
65
65
|
config.templates?.forEach(el => addTemplateDir(el));
|
package/package.json
CHANGED
|
@@ -77,18 +77,18 @@ export default async function suggest(req) {
|
|
|
77
77
|
if (arr && query.token && query.column) {
|
|
78
78
|
const loadTable = await getTemplate('table', query.token);
|
|
79
79
|
|
|
80
|
-
const { columns = [] } = await getMeta({ pg, table: tableName });
|
|
80
|
+
const { columns = [] } = await getMeta({ pg, table: loadTable?.table || tableName });
|
|
81
81
|
|
|
82
82
|
const column = columns.find(el => el.name === query.column);
|
|
83
83
|
const args = { table: tableName };
|
|
84
84
|
if (!column) return [];
|
|
85
|
-
const sqlCls = `select array_agg(distinct value) from (select ${pg.pgType?.[column.dataTypeID]?.includes('[]') ? `unnest(${column.name})` : `${column.name}`} as value from ${(tableName).replace(/'/g, "''")} where ${hookBody?.query || loadTable?.query || '1=1'})q`;
|
|
85
|
+
const sqlCls = `select array_agg(distinct value)::text[] from (select ${pg.pgType?.[column.dataTypeID]?.includes('[]') ? `unnest(${column.name})` : `${column.name}`} as value from ${(loadTable?.table || tableName).replace(/'/g, "''")} where ${hookBody?.query || loadTable?.query || '1=1'})q`;
|
|
86
86
|
|
|
87
87
|
if (query.sql && (config.local || user?.user_type?.includes?.('admin'))) {
|
|
88
88
|
return sqlCls;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (pg.pk?.[tableName] && column?.name) {
|
|
91
|
+
if (pg.pk?.[loadTable?.table || tableName] && column?.name) {
|
|
92
92
|
const vals = await pg.queryCache(sqlCls, args).then(el => el.rows?.[0]?.array_agg || []);
|
|
93
93
|
// console.log(vals);
|
|
94
94
|
|
|
@@ -97,7 +97,7 @@ export default async function suggest(req) {
|
|
|
97
97
|
? arr?.filter((el) => !lower || (el[lang] || el.text)?.toLowerCase()?.indexOf(lower) !== -1)?.filter((el) => !query.val || el.id === query.val)
|
|
98
98
|
: arr;
|
|
99
99
|
|
|
100
|
-
const data2 = data1.filter((el) => vals.includes(el.id));
|
|
100
|
+
const data2 = data1.filter((el) => el.id && vals.includes(el.id.toString()));
|
|
101
101
|
const data = data2.slice(0, Math.min(query.limit || limit, limit));
|
|
102
102
|
return {
|
|
103
103
|
time: Date.now() - time,
|