Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The store.update function works incorrectly when the $set fields contain only null values. #1758

Closed
Matosov opened this issue Mar 18, 2021 · 2 comments
Assignees
Labels
bug Issues related to defects and incorrect/unexpected feature behavior

Comments

@Matosov
Copy link

Matosov commented Mar 18, 2021

For instance the following update
await store.update('Tickets', { id: aggregateId }, { $set: { contactId: null, contactName: null } });
leads to the error:
[{"code": "BadRequestException", "name": "BadRequestException", "stack": "BadRequestException: ERROR: syntax error at or near "WHERE"\n Position: 58\n at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)\n at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)\n at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)\n at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)\n at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)\n at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)\n at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10\n at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)\n at Request. (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)", "message": "ERROR: syntax error at or near "WHERE"\n Position: 58"}].

@MrCheater
Copy link
Contributor

await store.update('Tickets', {​​​​​​​​ id: aggregateId }​​​​​​​​, {​​​​​​​​ $set: {​​​​​​​​ contactId:null, contactName:null }​​​​​​​​ }​​​​​​​​)

->

UPDATE "readmodel-prod-0.28.2-xxxxxx"."Tickets"
    SET  WHERE 
    ((("id" = CAST('"e3370191-9db0-449a-bf50-e7b0d45cbb55"' AS JSONB)) and (not ("id" is null)) and (not (CAST('"e3370191-9db0-449a-bf50-e7b0d45cbb55"' AS JSONB) is null))) or      
    (("id" is null) and (CAST('"e3370191-9db0-449a-bf50-e7b0d45cbb55"' AS JSONB) is null)))
   ;

@MrCheater MrCheater added bug Issues related to defects and incorrect/unexpected feature behavior Component: readmodel-adapters labels Apr 13, 2021
@MrCheater
Copy link
Contributor

Fixed in version 0.29.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to defects and incorrect/unexpected feature behavior
Projects
None yet
Development

No branches or pull requests

3 participants