did something (undocumented?) change with SuiteQL ...
# suiteql
d
did something (undocumented?) change with SuiteQL
COUNT
? this used to work:
const queryStr = 'SELECT COUNT(*) AS recordcount FROM xxxxx';
, getting recordcount alias, but now comes back as
expr1
it seems? didn't know if this now to be expected, or is better way to phrase query so that Oracle SQL interprets it correctly
c
How are you executing your query? When do the above using
query.runSuiteQL(queryStr).asMappedResults()
I am getting
recordcount
as the column name, not
expr1
d
this is running in browser console, but is also occurring in context of REST Api, which is where I noticed originally
also just confirmed with serverside debugger as well
t
@dbarnett I wonder if SuiteQL is using "recordcount" internally, and to resolve the collision, it's ignoring your alias. Have you tried using something else as the alias?
d
I had not, although just updated the alias to be
xxx
instead, but no luck/same result of
expr1
t
Weird. It's working for me.
Ok, so another potential option: Wrap the alias in double-quotes? ex:
SELECT COUNT(*) AS *"recordcount"* FROM Employee
d
nope 😞 very weird
t
Very weird, and worrisome, too. because if aliases start breaking, all kinds of other things are likely to break, too.
Is it only happening to aliases on the COUNT? Have you tried other aliases?
d
this is TSDRV account (tried in multiple) so maybe some (hopefully temporary) weirdness going on there and will just resolve itself
yah seems maybe just when some kind of expression, took a normal field just now and properly aliased the column
t
Ok, so one more goofy suggestion: Maybe wrap COUNT in parens? ex:
SELECT ( COUNT(*) ) AS recordcount FROM Employee
d
ohhh weird I just did
COUNT(id)
to try that out and worked 😂
t
What table were you querying?
My guess: either Transaction or Entity
d
Employee same (wrong) behavior with Transaction as well though
t
Well, I'm glad you have a fix. That is still really strange.
👍 1
t
Sorry for bringing this up again... Was the "solution" to the problem to count on id instead of * ? We're experiencing the same "broken alias" behaviour in our production enviroment.
d
@Thorsten Schmitz yes, use
COUNT(id)
instead
t
Ok, thanks! Just out of curiosity, did you see any other problems with aliases like simple
SELECT id AS myIdAlias FROM table
?
d
no, if you scroll up a bit in prior conversation I did try that as a sanity check - a normal field on table did properly alias; seemed to just be an issue when expression was involved
👍 1
n
Super strange bug - modifying the
COUNT(*)
to
COUNT(id)
was a fix for me.
a
Also ran into this. Went and removed any instances of
COUNT(*)
to be sure
d
is this still a fix? just ran
SELECT COUNT(id) FROM Transaction
... coming back with
expr1
again 😞
t
@dbarnett It's working for me. In your example, did you forget to add the alias?
d
@tdietrich ah nevermind lol not enough coffee this friday morning