SpacetimeDB
SpacetimeDB copied to clipboard
SQL parser breaks for columns named `position`
Hey, Apparently it's an invalid keyword,
TL;DR:
🪐spacetime-server>select * from transforms
id | gameObjectId | position
----+--------------+----------
(0 rows)
Time: 1.79ms
🪐spacetime-server>select position from transforms
sql parser error: Expected (, found: from at Line: 1, Column 17
🪐spacetime-server>select positio from transforms
`positio` is not in scope
🪐spacetime-server>select gameObjectId from transforms
gameObjectId
--------------
(0 rows)
Time: 1.92ms
🪐spacetime-server>select id, gameObjectId from transforms
id | gameObjectId
----+--------------
(0 rows)
Time: 1.73ms
🪐spacetime-server>select id, gameObjectId, position from transforms
sql parser error: Expected (, found: from at Line: 1, Column 35
Server logs:
WARN /home/ubuntu/actions-runner-linux-x64-2.309.0/_work/SpacetimeDB/SpacetimeDB/crates/client-api/src/lib.rs:100: sql parser error: Expected (, found: from at Line: 1, Column 17
WARN /home/ubuntu/actions-runner-linux-x64-2.309.0/_work/SpacetimeDB/SpacetimeDB/crates/client-api/src/lib.rs:100: sql parser error: Expected (, found: from at Line: 1, Column 35
First I spotted it on the client:
bundle.min.js:92063 Subscription failure for 2 queries!: sql parser error: Expected (, found: FROM at Line: 1, Column 17
Queries:
SELECT position FROM transforms WHERE gameObjectId = 38,SELECT velocity, acceleration, mass FROM rigidbodies WHERE gameObjectId = 38
Documentation leads to 0 results when searching for "position" from https://spacetimedb.com/docs/sql
Our parser treats POSITION as a reserved function name. You can get around this by using quoted identifiers:
SELECT "position" FROM transforms
I'm going to close this issue. @puttehi feel free to reopen if you're still having trouble!