Argh- Math function won't work on an integer
I am reading an integer field and trying to add or subtract on it, and get the following error.
"Variable is not text. Are you referencing a full object?" I have confirmed that the field is an integer field in the database, and even tried using the "To_Int" function on the field before the math.
What am I doing wrong— this feels like a bust.
Answers
-
Holy cow, it appears the problem was that I was accessing the "vote" field from the object provided by a query.
When I accessed that same field on the same object with the "get" function, the math operation succeeded.
In other words, if I want to query a table for an entry, and upvote that entry, it appears I can't do that, because the math fails when accessing the integer fields of the object when pulled with a query.
Is this the expect behavior. (see attached for the two ways I pulled the entry featurevote; the disabled one gave the error above).
-
Wow. Apparently it was this. Super non-obvious that the object I was returning was a list and not an object. Changed output of query to "single" instead of list. Hope to get the last 4 hours back at some point.
-
by default query all records returns an array. Even when it returns one record/ it’s a list of one. Either you need to unwrap the array before your manipulation or change the return type to “single” (which makes it a more flexible version of get record- which I suspect is what you were going for!). Change the type by going to the output tab of query all records and clicking on the pencil next to the word “return”
-
Thanks Ray. That was it. You can imagine my confusion when I successfully could pull an integer field from the query result (e.g. "6") when the output was a list, but all operations with "6" failed. I changed the output type to single and am off to the races.
-
Now trying to figure out how to "unwrap" an array in a different context, but no joy in searching. (one allusion to unwrapping on statechange, but it was very specific).
This looks like it'd come up a lot, but now that I have an array inside of a table entry, like in the video below, after some trial and error, I was able to return the data table containing the array, and then use dot notation to assign just the field containing the array to a new object, giving me a "single level" array like I wanted. Maybe this tidbit will save someone some time down the road.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback