@opengis/fastify-table 1.2.67 → 1.2.68
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
|
@@ -45,7 +45,9 @@ export default async function dataAPI(req, reply, called) {
|
|
|
45
45
|
} else if (checkInline[params?.table]) {
|
|
46
46
|
loadTable.sql = checkInline[params?.table]
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
if (query.sql == 2) {
|
|
49
|
+
return loadTable;
|
|
50
|
+
}
|
|
49
51
|
if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table])) { return { message: 'template not found', status: 404 }; }
|
|
50
52
|
|
|
51
53
|
const id = tokenData?.id || hookData?.id || params?.id;
|
|
@@ -131,7 +133,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
131
133
|
const q = `select ${pk ? `"${pk}" as id,` : ''}
|
|
132
134
|
${params.id || query.key ? '*' : sqlColumns || cols || '*'}
|
|
133
135
|
${metaCols}
|
|
134
|
-
${sql?.filter(el => el.inline).map(el => `,(${el.sql})`).join('')}
|
|
136
|
+
${sql?.filter(el => el.inline).map(el => `,(${el.sql})`).join('') || ''}
|
|
135
137
|
|
|
136
138
|
${dbColumns.find((el) => el.name === 'geom' && pg.pgType?.[el.dataTypeID] === 'geometry') ? ',st_asgeojson(geom)::json as geom' : ''}
|
|
137
139
|
from (select * from ${table} where ${sqlTable ? 'true' : (where.join(' and ') || 'true')} ) t
|
|
@@ -72,8 +72,8 @@ export default async function suggest(req) {
|
|
|
72
72
|
|
|
73
73
|
const column = columns.find(el => el.name === query.column);
|
|
74
74
|
const args = { table: tableName };
|
|
75
|
-
|
|
76
|
-
const sqlCls = `select array_agg(distinct value) from (select ${pg.pgType?.[column.dataTypeID]
|
|
75
|
+
if (!column) return [];
|
|
76
|
+
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`;
|
|
77
77
|
|
|
78
78
|
if (query.sql && (config.local || user?.user_type?.includes?.('admin'))) {
|
|
79
79
|
return sqlCls;
|