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

Addressed inconsistency with remove and delete functionality betw… #183

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,8 @@ All notable changes to this project will be documented in this file. Breaking ch

## [2.3.2] - 2022-11-23
### Fixed
- Upsert method would silently disregard `where` clause usage, and would not add condition expression to parameters.
- Upsert method would silently disregard `where` clause usage, and would not add condition expression to parameters.

## [2.3.3] - 2022-11-28
### Fixed
- Issue #182: Addressed inconsistency with `remove` and `delete` functionality between `update` and `patch` methods.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electrodb",
"version": "2.3.2",
"version": "2.3.3",
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/clauses.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ let clauses = {
return state;
}
},
children: ["set", "append", "remove", "add", "subtract", "data"],
children: ["set", "append","updateRemove", "updateDelete", "add", "subtract", "data"],
},
update: {
name: "update",
Expand Down
57 changes: 56 additions & 1 deletion test/ts_connected.update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ describe("Update Item", () => {
expect(dataRemoveError.message).to.equal(`Attribute "createdAt" is Read-Only and cannot be updated - For more detail on this error reference: https://github.com/tywalch/electrodb#invalid-attribute`);
});

it("should remove properties from an item", async () => {
it("should remove properties from an item via the update method", async () => {
const repoName = uuid();
const repoOwner = uuid();
const createdAt = "2021-07-01";
Expand Down Expand Up @@ -2516,6 +2516,61 @@ describe("Update Item", () => {
});
});

it("should remove properties from an item via the patch method", async () => {
const repoName = uuid();
const repoOwner = uuid();
const createdAt = "2021-07-01";
await repositories
.put({
repoName,
repoOwner,
createdAt,
isPrivate: false,
license: "apache-2.0",
description: "my description",
recentCommits: [
{
sha: "8ca4d4b2",
data: "1627158426",
message: "fixing bug"
},
{
sha: "25d68f54",
data: "1627158100",
message: "adding bug"
}
],
stars: 10,
defaultBranch: "main",
tags: ["tag1", "tag2"]
})
.go();

await repositories
.patch({repoName, repoOwner})
.remove([
"license",
"description",
"recentCommits",
"stars",
"defaultBranch",
"tags",
])
.go();

const item = await repositories
.get({repoName, repoOwner})
.go().then(res => res.data);

expect(item).to.deep.equal({
createdAt,
repoOwner,
repoName,
username: repoOwner,
isPrivate: false,
});
});

it("should remove properties from an item with data method", async () => {
const repoName = uuid();
const repoOwner = uuid();
Expand Down