@opengis/fastify-table 1.3.26 → 1.3.28
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
|
@@ -56,6 +56,7 @@ ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS tags text[];
|
|
|
56
56
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS file_path text;
|
|
57
57
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS ismain boolean default false;
|
|
58
58
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS isverified boolean default false;
|
|
59
|
+
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS resized boolean;
|
|
59
60
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS uid text;
|
|
60
61
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS files json;
|
|
61
62
|
ALTER TABLE crm.files ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
@@ -28,6 +28,7 @@ export default async function dataInsert({
|
|
|
28
28
|
if (!columns) return null;
|
|
29
29
|
|
|
30
30
|
const names = columns.map((el) => el.name);
|
|
31
|
+
const types = columns.reduce((acc, { name, dataTypeID }) => ({ ...acc, [name]: pg.pgType?.[dataTypeID] }), {});
|
|
31
32
|
|
|
32
33
|
Object.assign(data, {
|
|
33
34
|
...(id && pg.pk?.[table] ? { [pg.pk?.[table]]: id } : {}),
|
|
@@ -50,7 +51,7 @@ export default async function dataInsert({
|
|
|
50
51
|
|
|
51
52
|
returning *`;
|
|
52
53
|
|
|
53
|
-
const res = await pg.query(insertQuery, [...filterData.map((el) => (typeof el[1] === 'object' ? JSON.stringify(el[1]) : el[1]))]).catch(err => {
|
|
54
|
+
const res = await pg.query(insertQuery, [...filterData.map((el) => (typeof el[1] === 'object' && types[el[0]]?.includes?.('json') ? JSON.stringify(el[1]) : el[1]))]).catch(err => {
|
|
54
55
|
logger.file('crud/insert', { error: err.toString(), stack: err.stack, table, id, referer, uid, data, q: insertQuery });
|
|
55
56
|
throw new Error(err.toString());
|
|
56
57
|
}) || {};
|
|
@@ -38,7 +38,10 @@ export default async function dataUpdate({
|
|
|
38
38
|
|
|
39
39
|
const { columns, pk } = await getMeta({ pg, table });
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
if (!columns) return null;
|
|
42
|
+
|
|
43
|
+
const names = columns.map((el) => el.name);
|
|
44
|
+
const types = columns.reduce((acc, { name, dataTypeID }) => ({ ...acc, [name]: pg.pgType?.[dataTypeID] }), {});
|
|
42
45
|
|
|
43
46
|
const filterData = Object.keys(data)
|
|
44
47
|
.filter((el) => (/* typeof data[el] === 'boolean' ? true : data[el] && */ names?.includes(el) && !['editor_date', 'editor_id'].includes(el)));
|
|
@@ -46,12 +49,12 @@ export default async function dataUpdate({
|
|
|
46
49
|
const systemColumns = [['editor_date', 'now()'], uid ? ['editor_id', `'${uid.replace(/'/g, "''")}'`] : []].filter((el) => names.includes(el[0])).map((el) => `${el[0]} = ${el[1]}`).join(',');
|
|
47
50
|
|
|
48
51
|
const filterValue = filterData.map((el) => {
|
|
49
|
-
const { dataTypeID = 25 } = columns
|
|
52
|
+
const { dataTypeID = 25 } = columns.find((col) => col?.name === el) || {};
|
|
50
53
|
if (pg.pgType[dataTypeID]?.endsWith('[]') && ['string', 'number'].includes(typeof data[el])) {
|
|
51
54
|
Object.assign(data, { [el]: data[el].split(',') });
|
|
52
55
|
}
|
|
53
56
|
return [el, data[el]];
|
|
54
|
-
}).map((el) => (typeof el[1] === 'object' && el[1] ? JSON.stringify(el[1]) : el[1]));
|
|
57
|
+
}).map((el) => (typeof el[1] === 'object' && types[el[0]]?.includes?.('json') && el[1] ? JSON.stringify(el[1]) : el[1]));
|
|
55
58
|
|
|
56
59
|
// update geometry with srid
|
|
57
60
|
if (!srids[table] && pg.tlist?.includes('public.geometry_columns')) {
|