Skip to content

Commit

Permalink
fix(sdk): fixing table methods (#4163)
Browse files Browse the repository at this point in the history
## Checklist

<img width="276" alt="image" src="https://github.com/winglang/wing/assets/39455181/6378c4a6-a15a-42ce-8ad1-e2a64f61cc6d">


- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
tsuf239 authored Sep 13, 2023
1 parent d634827 commit 899ebde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libs/wingsdk/src/shared-aws/table.inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class TableClient implements ITableClient {
const command = new PutItemCommand({
TableName: this.tableName,
Item: marshall(insertRow),
ConditionExpression: `attribute_not_exists(${this.primaryKey})`,
ConditionExpression: `attribute_not_exists(#primary_key)`,
ExpressionAttributeNames: {
"#primary_key": this.primaryKey,
},
});
await this.client.send(command);
} catch (e) {
Expand Down
5 changes: 4 additions & 1 deletion libs/wingsdk/src/target-tf-aws/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export class Table extends ex.Table {
throw new Error("tables can only be bound by tfaws.Function for now");
}

if (ops.includes(ex.TableInflightMethods.INSERT)) {
if (
ops.includes(ex.TableInflightMethods.INSERT) ||
ops.includes(ex.TableInflightMethods.UPSERT)
) {
host.addPolicyStatements([
{
actions: ["dynamodb:PutItem"],
Expand Down

0 comments on commit 899ebde

Please sign in to comment.