Skip to content

RLS Documentation - Invalid SQL Query #351

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

Merged
merged 1 commit into from
May 22, 2025

Conversation

wes-sleeman
Copy link
Contributor

@wes-sleeman wes-sleeman commented May 22, 2025

The RLS documentation included a number of queries of the form SELECT * FROM account WHERE identity = :sender. Any attempt to deploy such an RLS query yields the below very unhelpful error:

spacetime publish -s maincloud <PROJECT_NAME> --project-path <PROJECT_FOLDER>
Optimising module with wasm-opt...
Build finished successfully.
You are about to publish to a non-local server: maincloud.spacetimedb.com
Are you sure you want to proceed? [y/N]y
Uploading to maincloud => https://maincloud.spacetimedb.com
Publishing module...
Error: Failed to create or update the database: Unsupported expression: identity

Caused by:
    HTTP status client error (400 Bad Request) for url (https://maincloud.spacetimedb.com/v1/database/<PROJECT_NAME>)

I tested this (in a C# module) with a couple different choices of column name and got the same result. After much hair-pulling, I read the actual parsing logic and found that the fix to this is to qualify the identity column as account.identity (tested and working locally and on maincloud). Reading through some of the other documentation, I have a sneaking suspicion that the unqualified column name is supposed to be permitted here, but this PR might save a few people some serious frustration along the way and can be reverted if/when this is determined to be a bug and a fix is published.

@wes-sleeman wes-sleeman force-pushed the wes/fix-rls-query-column branch from 240ad39 to 686e4c2 Compare May 22, 2025 02:42
@gefjon gefjon enabled auto-merge (squash) May 22, 2025 13:47
@gefjon gefjon merged commit 3b5c091 into clockworklabs:master May 22, 2025
3 checks passed
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.

2 participants