Skip to content

Conversation

@cloutierMat
Copy link
Member

@cloutierMat cloutierMat commented Jun 11, 2025

Motivation

This pr implements support for attributeExists in rds where clause.

The customer sample was also failing as part of the logic in the where clause was missing.

Changes

  • Added support for attributeExists
  • Allow for multiple blocks on the same level. The previous logic would, in order, either process or, process and or process a single clause. But only the first of these items would actually make it part of the SQL query.
  • allow for nested and/or clause. We are calling buildWhereClause recursively to correctly build nested and/or clauses.
  • buildWhereClause now correctly returns a string. All usage of buildWhereClause were adding it in a string literal. This would create invalid SQL statement if an array is returned.

Other fixes along the way

  • Updated node version to 18 as this is the current version used inside LocalStack
  • Fixed Date usage in some test, as they would fail in a non UTC environment

@cloutierMat cloutierMat marked this pull request as ready for review June 12, 2025 19:21
@cloutierMat cloutierMat requested a review from simonrw June 12, 2025 19:21
@cloutierMat

This comment was marked as resolved.

Copy link
Collaborator

@simonrw simonrw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this improvement!

In general I am not a fan of us writing our own character-to-character SQL generator in this library, so I'd love to hear your thoughts on where we go from here.

env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_API_KEY }}
TEST_IMAGE_NAME: public.ecr.aws/lambda/nodejs:16
TEST_IMAGE_NAME: public.ecr.aws/lambda/nodejs:18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er... we are still using 16 (for better or worse...) https://github.com/localstack/localstack-ext/blob/1f952f304e39d1d066a4d703a2727b395bf8af9e/localstack-pro-core/localstack/pro/core/services/appsync/mapping.py#L25

However we do want to move our JS execution to the node in the container image, so this is a good move, thanks! 👍

case "notContains":
return `${startGrouping}${this.quoteChar}${columnName}${this.quoteChar} NOT LIKE ${value}${endGrouping}`;
case "attributeExists":
return `${startGrouping}${this.quoteChar}${columnName}${this.quoteChar} IS ${value? "NOT " : ""}NULL${endGrouping}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a super fan of this ternary operator, but it's quite common in JS so I'm ok with it.

@cloutierMat cloutierMat merged commit a981062 into main Jun 17, 2025
4 checks passed
@cloutierMat cloutierMat deleted the support-attributeExists branch June 17, 2025 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants