Skip to content

Commit

Permalink
fix json merge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Feb 22, 2024
1 parent e1fa130 commit 2ec4af4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/DboBuilder/TableHandler/DataValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ const convertionFuncs: ConvertionFunc[] = [
onlyAllowedFor: "update",
getQuery: ({ args, column }) => {
if (!args.length) throw "merge function requires at least one argument";
const argList = args.map(arg => asValue(arg)).join(" || ");
return `${asName(column.name)} || ${argList}`;
const argVals = args.map(arg => asValue(arg))
const argList = argVals.join(" || ");
return `COALESCE(${asName(column.name)}, ${argVals.join(", ")}) || ${argList}`;
}
}
];
Expand Down
5 changes: 3 additions & 2 deletions lib/FileManager/FileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ export class FileManager {
const { colName, tableName } = args;
const tableConfig = this.prostgles?.opts.fileTable?.referencedTables?.[tableName];
const isReferencingFileTable = this.dbo[tableName]?.columns?.some(c => c.name === colName && c.references && c.references?.some(({ ftable }) => ftable === this.tableName ));
const allowAllFiles = { acceptedContent: "*" } as const;
if(isReferencingFileTable){
if(tableConfig && typeof tableConfig !== "string"){
return tableConfig.referenceColumns[colName];
return tableConfig.referenceColumns[colName] ?? allowAllFiles;
}
return { acceptedContent: "*" };
return allowAllFiles;
}
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prostgles-server",
"version": "4.2.19",
"version": "4.2.20",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ec4af4

Please sign in to comment.