Patrick
12/12/2023, 7:03 PMdavequested
12/12/2023, 9:26 PMAdam Cameron
someQuery.someColumn[someRow].getClass().getName())?
What does its toString method give you?
Can you also clarify "outputs", you mean (eg): <cfoutput>#someQuery.someColumn[someRow]#</cfoutput>?Patrick
12/13/2023, 2:59 PM0.000000000000Patrick
12/13/2023, 3:03 PMAdam Cameron
numberFormat is the tool for the job here. Interesting bug in Lucee surfaced by this:
https://trycf.com/gist/9c4509396b9bdb5b0b9a076c51161af8/lucee5?theme=monokai
note this bit:
Using writeOutput & numberFormat with 0s: 0.000000000001
Using writeOutput & numberFormat with 9s: 0.000000000000
(cf with CF)Patrick
12/13/2023, 3:18 PMPatrick
12/13/2023, 3:19 PMPatrick
12/13/2023, 3:25 PMAdam Cameron
0. This is what I'd expect.
I'd need to see a (standalone) repro of you getting scientific notation out of a BigDecimal being output to be able to comment further.
Also: forget about <cfdump>, it's a debugging tool. It might be trying to be "helpful". That's not how you are going to be using that data, so how is it displaying for you in "actual usage"?Patrick
12/13/2023, 5:39 PMPatrick
12/13/2023, 5:40 PMPatrick
12/13/2023, 5:41 PMAdam Cameron
Well by "as expected" I meant output exactly how displayed in the database.See this is why I'm checking your expectations. "displayed in the DB". It's not displaying in the DB. it's stored in the DB. You can't "see it" in the DB. And in the DB it's stored as some sort of sequence of bytes, in binary. You don't want to "see" that, do you? No. You're looking at a DB client, and that's where it's being displayed. These are two separate things. And I'm not being pedantic: this is important to understand. A DB client is one sort of software, and it has its own UI/UX expectations. A CFML application server is acting as a data interchange mechanism. And you are writing the UI for this data interchange. The CFML server has some rules if you ask it to output the binary data it has from the DB, and those rules are arbitrary (and sometimes unhelpful based on your current definition of "helpful", which it can't guess). If you wanna format this data in a specific way in the UI that you are creating... this is on you. --- I'm over-egging that a bit for the sake of clarity, but this is what's going on. And hopefully an explanation of a value "output[ing] exactly how displayed in the database [client]" isn't... quite so cut and dried as you make it seem. If you want values to be in a certain format: format them. That's what the DB client you're looking at is doing.
Patrick
12/13/2023, 7:19 PMPatrick
12/13/2023, 7:21 PMkuro5
12/14/2023, 12:20 AMPatrick
12/14/2023, 12:28 AMAdam Cameron
toString), it followed well-defined rules. Why those specific rules? [shrug], but it will be for a well-informed reason. it is Java, after all.
And Java provides the toPlainString method as per above, and CFML provides numberFormat (as per slightly more above).
If you ask for less precision, then at a point, it'll start returning a std decimal number.