Skip to content

Commit

Permalink
The execution option { compare: "attributes" } used incorrect expre…
Browse files Browse the repository at this point in the history
…ssion comparisons that impacted `lte` queries on indexes with a single composite key.
  • Loading branch information
tywalch committed Oct 20, 2024
1 parent 8a33912 commit c788e84
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,7 @@ All notable changes to this project will be documented in this file. Breaking ch
- The execution options `includeKeys` and `raw` were deprecated in version `2.0.0` and have now been removed in favor of the execution option `data`. To migrate from `v2`, use the options `{ data: "includeKeys" }` and `{ data: "raw" }` respectively.
### Fixed
- Response typing and formatting logic for `delete`

## [3.0.1]
### Fixed
- The execution option `{ compare: "attributes" }` used incorrect expression comparisons that impacted `lte` queries on indexes with a single composite key.
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": "3.0.0",
"version": "3.0.1",
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
"main": "index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,6 @@ class Entity {
if (skType === "number") {
return Comparisons[comparison];
} else if (
comparisonType === ComparisonTypes.attributes ||
comparisonType === ComparisonTypes.v2
) {
return KeyAttributesComparisons[comparison];
Expand Down
16 changes: 8 additions & 8 deletions test/generation/comparisonTests/testCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$clusteredregion#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 >= :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 > :sk1",
"IndexName": "gsi1pk-gsi1sk-index",
"FilterExpression": "(#city > :city0) AND (#county > :county0) AND (#__edb_e__ = :__edb_e__0) AND #__edb_v__ = :__edb_v__0"
},
Expand Down Expand Up @@ -520,7 +520,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$isolatedregion#attraction_1#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 >= :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 > :sk1",
"IndexName": "gsi2pk-gsi2sk-index",
"FilterExpression": "(#city > :city0) AND #county > :county0"
},
Expand Down Expand Up @@ -570,7 +570,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$attraction_1#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 >= :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 > :sk1",
"FilterExpression": "(#city > :city0) AND #county > :county0"
},
"evaluations": [
Expand Down Expand Up @@ -623,7 +623,7 @@
":__edb_e___Attraction": "attraction",
":__edb_v___Attraction": "1"
},
"KeyConditionExpression": "#pk = :pk and #sk1 >= :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 > :sk1",
"IndexName": "gsi1pk-gsi1sk-index",
"FilterExpression": "(#__edb_e__ = :__edb_e___Attraction AND #__edb_v__ = :__edb_v___Attraction) AND (#city > :city0) AND #county > :county0"
},
Expand Down Expand Up @@ -893,7 +893,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$clusteredregion#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 < :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 <= :sk1",
"IndexName": "gsi1pk-gsi1sk-index",
"FilterExpression": "(#city <= :city0) AND (#county <= :county0) AND (#__edb_e__ = :__edb_e__0) AND #__edb_v__ = :__edb_v__0"
},
Expand Down Expand Up @@ -952,7 +952,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$isolatedregion#attraction_1#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 < :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 <= :sk1",
"IndexName": "gsi2pk-gsi2sk-index",
"FilterExpression": "(#city <= :city0) AND #county <= :county0"
},
Expand Down Expand Up @@ -1002,7 +1002,7 @@
":pk": "$comparison#country_usa#state_wisconsin",
":sk1": "$attraction_1#county_dane#city_madison"
},
"KeyConditionExpression": "#pk = :pk and #sk1 < :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 <= :sk1",
"FilterExpression": "(#city <= :city0) AND #county <= :county0"
},
"evaluations": [
Expand Down Expand Up @@ -1055,7 +1055,7 @@
":__edb_e___Attraction": "attraction",
":__edb_v___Attraction": "1"
},
"KeyConditionExpression": "#pk = :pk and #sk1 < :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 <= :sk1",
"IndexName": "gsi1pk-gsi1sk-index",
"FilterExpression": "(#__edb_e__ = :__edb_e___Attraction AND #__edb_v__ = :__edb_v___Attraction) AND (#city <= :city0) AND #county <= :county0"
},
Expand Down
4 changes: 2 additions & 2 deletions test/ts_connected.entity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5015,7 +5015,7 @@ describe('execution option compare', () => {
":sk1": "$inregion#county_dane#city_madison",
},
"FilterExpression": "(#city > :city0) AND (#county > :county0) AND (#__edb_e__ = :__edb_e__0) AND #__edb_v__ = :__edb_v__0",
"KeyConditionExpression": "#pk = :pk and #sk1 >= :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 > :sk1",
"TableName": "electro"
});
expect(v2Params).to.deep.equal({
Expand Down Expand Up @@ -5082,7 +5082,7 @@ describe('execution option compare', () => {
":sk1": "$inregion#county_dane#city_madison",
},
"FilterExpression": "(#city <= :city0) AND (#county <= :county0) AND (#__edb_e__ = :__edb_e__0) AND #__edb_v__ = :__edb_v__0",
"KeyConditionExpression": "#pk = :pk and #sk1 < :sk1",
"KeyConditionExpression": "#pk = :pk and #sk1 <= :sk1",
"TableName": "electro"
});
expect(v2Params).to.deep.equal({
Expand Down

0 comments on commit c788e84

Please sign in to comment.