@opengis/fastify-table 1.4.4 → 1.4.5
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
|
@@ -32,7 +32,7 @@ export default async function getFilterSQL({
|
|
|
32
32
|
const extraDataTable = extra
|
|
33
33
|
? config.extraData?.[body.table]
|
|
34
34
|
|| config.extraData?.[body.table.split('.').shift()]
|
|
35
|
-
|| config.extraData?.
|
|
35
|
+
|| config.extraData?.default
|
|
36
36
|
|| config.extraData
|
|
37
37
|
|| defaultTable
|
|
38
38
|
: undefined;
|
|
@@ -131,7 +131,10 @@ export default async function getFilterSQL({
|
|
|
131
131
|
|
|
132
132
|
// table
|
|
133
133
|
|
|
134
|
-
const obj = {
|
|
134
|
+
const obj = {
|
|
135
|
+
body, extraSqlColumns, table, q,
|
|
136
|
+
};
|
|
137
|
+
|
|
135
138
|
const optimizedSQL = `select * from ${getOptimizedQuery(obj)} `;
|
|
136
139
|
const tableCount = getOptimizedQuery(obj, true);
|
|
137
140
|
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
import applyHookSync from
|
|
2
|
-
import getRangeQuery from
|
|
1
|
+
import applyHookSync from '../../../../hook/funcs/applyHookSync.js';
|
|
2
|
+
import getRangeQuery from './getRangeQuery.js';
|
|
3
3
|
|
|
4
4
|
export default function formatValue({
|
|
5
5
|
pg, table, filter = {}, name, value, dataTypeID, uid = 1, optimize,
|
|
6
6
|
}) {
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
extra, sql, select, strict, options, default: defaultValue,
|
|
9
|
+
} = filter;
|
|
10
|
+
|
|
8
11
|
const pk = pg?.pk && table ? pg.pk[table] : undefined;
|
|
9
12
|
|
|
13
|
+
if (name === 'search' && value && filter?.id) {
|
|
14
|
+
const columns = filter.id.split(',');
|
|
15
|
+
const sval = `ilike '%${decodeURIComponent(value.replace(/%/g, '%25')).replace(/%/g, '\\%')}%'`;
|
|
16
|
+
const query = `${columns.map(el => `"${el}" ${sval}`).join(' or ')}`;
|
|
17
|
+
return { op: '~', query };
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
const filterType = filter.type?.toLowerCase() || 'text';
|
|
11
21
|
const fieldType = pg?.pgType?.[dataTypeID] || pg?.pgType?.[{ date: 1114 }[filterType] || 25];
|
|
12
22
|
|
|
13
23
|
const hookData = applyHookSync('onFormatValue', {
|
|
14
24
|
pg, pk, table, name, value, filterType, fieldType, filter, dataTypeID, uid, optimize,
|
|
15
25
|
});
|
|
26
|
+
|
|
16
27
|
if (hookData) {
|
|
17
28
|
return hookData?.query ? hookData : { op: '=', query: hookData };
|
|
18
29
|
}
|
|
@@ -21,7 +32,7 @@ export default function formatValue({
|
|
|
21
32
|
|| !value
|
|
22
33
|
|| (!dataTypeID && !extra && !sql && !options)
|
|
23
34
|
|| extra?.input?.toLowerCase?.() === 'datatable'
|
|
24
|
-
|| !['check', 'autocomplete', 'tags', 'avatar', 'radio'].includes(filterType) && options?.find?.(el => el?.sql)
|
|
35
|
+
|| (!['check', 'autocomplete', 'tags', 'avatar', 'radio'].includes(filterType) && options?.find?.(el => el?.sql))
|
|
25
36
|
) {
|
|
26
37
|
return {};
|
|
27
38
|
}
|
|
@@ -35,7 +35,9 @@ function getFilterQuery({
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// filter
|
|
38
|
-
const filter = filterList?.find?.((el) => el.type && el.
|
|
38
|
+
const filter = filterList?.find?.((el) => el.type === 'search' && el.id)
|
|
39
|
+
|| filterList?.find?.((el) => el.type && el.name === name)
|
|
40
|
+
|| { type: 'text' };
|
|
39
41
|
const { strict, extra } = filter;
|
|
40
42
|
|
|
41
43
|
// find all value
|