@opengis/fastify-table 2.0.69 → 2.0.70
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/search.ts"],"names":[],"mappings":"AA6HA,wBAA8B,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAU,EAAE,EAAE,GAAG;;;;;;GAoClE"}
|
|
@@ -27,16 +27,20 @@ async function getData({ pg, tableName, query = {}, maxLimit, res }) {
|
|
|
27
27
|
? `(${meta?.search
|
|
28
28
|
.concat(meta?.title ? `,${meta?.title}` : "")
|
|
29
29
|
.split(",")
|
|
30
|
-
.map((el) => `${el} ilike '%${query.key}%'`)
|
|
30
|
+
.map((el) => `${el}::text ilike '%${query.key}%'`)
|
|
31
31
|
.join(" or ")})`
|
|
32
32
|
: "false";
|
|
33
33
|
const where = [!pk ? "false" : "true", loadTable.query, search1].filter(Boolean);
|
|
34
|
+
const sqlTable = loadTable.sql
|
|
35
|
+
?.filter?.((el) => !el?.disabled)
|
|
36
|
+
?.map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)
|
|
37
|
+
?.join?.("") || "";
|
|
34
38
|
const q = `select ${[
|
|
35
39
|
`"${pk}" as id`,
|
|
36
40
|
meta?.title ? `${meta.title} as title` : "",
|
|
37
41
|
]
|
|
38
42
|
.filter((el) => el)
|
|
39
|
-
.join(",")} from ${table} t where ${where.join(" and ") || "true"} ${order} ${offset} limit ${limit}`;
|
|
43
|
+
.join(",")} from ${table} t ${sqlTable} where ${where.join(" and ") || "true"} ${order} ${offset} limit ${limit}`;
|
|
40
44
|
if (query.sql) {
|
|
41
45
|
res.sql.push(q);
|
|
42
46
|
return null;
|
|
@@ -44,7 +48,7 @@ async function getData({ pg, tableName, query = {}, maxLimit, res }) {
|
|
|
44
48
|
const rows = await pg.query(q).then((el) => el.rows || []);
|
|
45
49
|
const filtered = pg.queryCache
|
|
46
50
|
? await pg
|
|
47
|
-
.queryCache(`select count(*) from ${table} t where ${where.join(" and ") || "true"}`)
|
|
51
|
+
.queryCache(`select count(*) from ${table} t ${sqlTable} where ${where.join(" and ") || "true"}`)
|
|
48
52
|
.then((el) => +(el?.rows[0]?.count || 0))
|
|
49
53
|
: 0;
|
|
50
54
|
const total = pg.queryCache
|