Skip to content

Commit

Permalink
fix onconflict doupdate bug
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Feb 22, 2024
1 parent 2ec4af4 commit 0d1287b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/DboBuilder/TableHandler/DataValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const convertionFuncs: ConvertionFunc[] = [
getQuery: ({ args }) => `to_timestamp(${asValue(args[0])}::BIGINT/1000.0)::timestamp`
}, {
name: "merge",
description: "Merge the provided jsonb objects into the existing column value",
description: "Merge the provided jsonb objects into the existing column value, ensuring that a null source value will be coalesced with provided values",
onlyAllowedFor: "update",
getQuery: ({ args, column }) => {
if (!args.length) throw "merge function requires at least one argument";
Expand Down
4 changes: 2 additions & 2 deletions lib/DboBuilder/TableHandler/insert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnyObject, InsertParams, isObject } from "prostgles-types";
import { AnyObject, InsertParams, asName, isObject } from "prostgles-types";
import { LocalParams, parseError, withUserRLS } from "../DboBuilder";
import { TableRule, ValidateRowBasic } from "../../PublishParser/PublishParser";
import { insertNestedRecords } from "../insertNestedRecords";
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function insert(this: TableHandler, rowOrRows: AnyObject | AnyObjec
if(!pkeyNames.length) {
throw "Cannot do DoUpdate on a table without a primary key";
}
const nonPkeyCols = allowedCols.filter(c => !pkeyNames.includes(c));
const nonPkeyCols = allowedCols.filter(c => !pkeyNames.includes(c)).map(v => asName(v));
if(!nonPkeyCols.length){
throw "Cannot on conflict DoUpdate on a table with only primary key columns";
}
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.20",
"version": "4.2.21",
"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 0d1287b

Please sign in to comment.