@opengis/fastify-table 1.1.28 → 1.1.29
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
CHANGED
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ function formatDateISOString(date) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function formatValue({
|
|
22
|
-
|
|
22
|
+
filterType, filter, name, value, operator = '=', fieldType = 'text', uid = 1, optimize,
|
|
23
23
|
}) {
|
|
24
24
|
if (!name || !value) return {};
|
|
25
25
|
|
|
@@ -105,7 +105,7 @@ function formatValue({
|
|
|
105
105
|
return { op: operator, query };
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
if (operator === '=' && filterType !== 'text') {
|
|
108
|
+
if (operator === '=' && filterType !== 'text' && !filter?.data) {
|
|
109
109
|
const query = {
|
|
110
110
|
null: `${name} is null`,
|
|
111
111
|
notnull: `${name} is not null`,
|
|
@@ -114,9 +114,12 @@ function formatValue({
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
if (['~', '='].includes(operator)) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const operator1 = (filterType === 'text' && (filter?.id || filter?.name) && operator === '=' ? '~' : operator);
|
|
118
|
+
const match = operator1 === '=' ? `='${value}'` : `ilike '%${value}%'`;
|
|
119
|
+
const query = filter?.data && filter?.sql
|
|
120
|
+
? `${filter?.name || filter?.id} in ( ( with q(id,name) as (${filter?.sql}) select id from q where name::text ${match}) )` // filter with cls
|
|
121
|
+
: `${name}::text ${match}`; // simple filter
|
|
122
|
+
// console.log(query);
|
|
120
123
|
return { op: 'ilike', query };
|
|
121
124
|
}
|
|
122
125
|
|
|
@@ -5,8 +5,8 @@ export default function obj2db(data, nonexistCol) {
|
|
|
5
5
|
|| !Object.keys(data || {}).length
|
|
6
6
|
) return { error: 'invalid data type' };
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const columns = existColumns?.filter((col) => data[col] || data?.[col] === 0);
|
|
8
|
+
const columns = Object.keys(data)?.filter((key) => !nonexistCol.includes(key));
|
|
9
|
+
// const columns = existColumns?.filter((col) => data[col] || data?.[col] === 0);
|
|
10
10
|
const args = columns?.map((col) => data[col]);
|
|
11
11
|
|
|
12
12
|
return { columns, args, error: !columns?.length ? 'nothing to process' : undefined };
|