strings returned as numbers in view collections? #3616
-
Hi, I'm seeing a really weird behavior where some queries in view collections would cast the result as a number if it looks like one inside a string field. There is more than one scenario in which this happens, but the one I could pinpoint it's really strange. I create a collection with string field called The funny thing is, as you can see in the first request it returns it as a string, the difference between the first and the second request is that I insert a space in the query after First request, view query: SELECT id, myfield, created FROM test; Second request, view query: SELECT id, myfield , created FROM test; I'm using and self-updated pocketbase_0.19.0_linux_amd64 and I have reproduced it on mac arm64. I suspect this might not be a bug in pocketbase but in the sqlite library. I have another query with the same issue, the one that led me to the problem, this one without the space, but I haven't figured out how to fix it yet. SELECT id, static, conversion, feed_scope, created
FROM (
SELECT *,
ROW_NUMBER() OVER(PARTITION BY feed_scope ORDER BY created DESC) as rn
FROM cpc_rules
WHERE valid_since < CURRENT_TIMESTAMP
) tmp
WHERE rn = 1; I would love to know what's going on here. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
It is most likely a bug with the PocketBase auto schema fields detection. Will try to check it later today.
You can try forcing a |
Beta Was this translation helpful? Give feedback.
-
That was the first thing I tried, but schema validation fails if I do. |
Beta Was this translation helpful? Give feedback.
-
🤦♂️ yeah that helped |
Beta Was this translation helpful? Give feedback.
The expression must be aliased so that it has a valid field name, aka. try with
CAST(myfield as TEXT) myfieldalias
.