Skip to content

Commit

Permalink
fixing table methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuf239 committed Sep 12, 2023
1 parent d634827 commit afda10c
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 afda10c

Please sign in to comment.