@opengis/fastify-table 1.1.37 → 1.1.38
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
|
@@ -69,7 +69,7 @@ COMMENT ON TABLE admin.user_properties IS 'Налаштування корист
|
|
|
69
69
|
|
|
70
70
|
CREATE TABLE IF NOT EXISTS admin.custom_column();
|
|
71
71
|
ALTER TABLE admin.custom_column DROP CONSTRAINT IF EXISTS admin_custom_column_column_id_pkey cascade;
|
|
72
|
-
alter table admin.custom_column drop constraint if exists
|
|
72
|
+
alter table admin.custom_column drop constraint if exists admin_custom_column_name_entity_uid_unique;
|
|
73
73
|
|
|
74
74
|
ALTER TABLE admin.custom_column ADD COLUMN IF NOT EXISTS column_id text;
|
|
75
75
|
ALTER TABLE admin.custom_column ALTER COLUMN column_id SET NOT NULL;
|
|
@@ -5,7 +5,7 @@ import { applyHook } from '../../utils.js';
|
|
|
5
5
|
|
|
6
6
|
export default async function tableAPI(req) {
|
|
7
7
|
const {
|
|
8
|
-
pg, params = {}, query = {}, opt = {},
|
|
8
|
+
pg, params = {}, query = {}, opt = {},
|
|
9
9
|
} = req;
|
|
10
10
|
if (!params.id) return { message: 'not enough params', status: 400 };
|
|
11
11
|
|
|
@@ -35,11 +35,11 @@ export default async function tableAPI(req) {
|
|
|
35
35
|
|
|
36
36
|
const { fields = [] } = !loadTable?.table ? await pg.query(`select * from ${table || opt?.table || params.table} limit 0`) : {};
|
|
37
37
|
const cols = loadTable?.table
|
|
38
|
-
? Object.keys(schema || {}).filter((col) => columnList.includes(col) && !extraKeys.includes(col))?.join(',')
|
|
38
|
+
? Object.keys(schema || {}).filter((col) => columnList.includes(col) && !extraKeys.includes(col))?.map((col) => (col?.includes('geom') ? `st_asgeojson(${col})::json as "${col}"` : `"${col}"`))?.join(',')
|
|
39
39
|
: fields.map((el) => (el?.name?.includes('geom') ? `st_asgeojson(${el.name})::json as "${el.name}"` : `"${el?.name}"`)).join(',');
|
|
40
40
|
const where = [`"${pk}" = $1`, loadTable.query].filter((el) => el);
|
|
41
|
-
const geom = columnList.includes('geom') ? 'st_asgeojson(geom)::json as geom
|
|
42
|
-
const q = `select "${pk}" as id, ${
|
|
41
|
+
const geom = columnList.includes('geom') ? ',st_asgeojson(geom)::json as geom' : '';
|
|
42
|
+
const q = `select "${pk}" as id, ${cols || '*'} ${geom} from ${table || opt?.table || params.table} t where ${where.join(' and ') || 'true'} limit 1`;
|
|
43
43
|
|
|
44
44
|
if (query.sql === '1') return q;
|
|
45
45
|
|