Has anyone an idea why Lucee would trim the whites...
# lucee
a
Has anyone an idea why Lucee would trim the whitespace within a column value? Here is an example I am storing a JSON string in a postgres column of type text like so
{"insert":"   displayName();"}
What I am getting on SELECT is this
{"insert":" displayName();"}
The whitespace before displayName() is reduced to only one space
d
Are you sure the whitespace is really being trimmed and it's not just an issue of the whitespace being collapsed (which would happen when rendering HTML)? Also, make sure it's actually multiple whitespace characters and not a tab that's being rendered differently.
a
I tried both, tabs and spaces.. both get reduced to only one whitespace
I can see the values are stored correctly in the DB
d
What are you doing to see the values are being trimmed? It it's in the DB correctly, what's the code you're using to verify it's trimming the whitespace?
a
dumping out the query
Screenshot 2024-01-31 at 11.07.45 AM.png
also, the corresponding JS editor shows only one space
d
Since that's going to render as HTML, the space is going to be collapsed.
a
untrue.. the editor takes in the JSON and converts that to HTML that gets rendered
d
If you're copying the JSON from the dump, it's going to be collapsed.
a
i added a hook to inject spaces before the editor gets it, and all gets displayed correctly
d
Instead of using dump, use echo(htmlCodeFormat(body)) instead
a
ok one sec
Copy code
<pre>{
    &quot;ops&quot;: [
        {
            &quot;insert&quot;: &quot;Header&quot;
        },
        {
            &quot;attributes&quot;: {
                &quot;header&quot;: 2
            },
            &quot;insert&quot;: &quot;\n&quot;
        },
        {
            &quot;insert&quot;: &quot;\n&quot;
        },
        {
            &quot;insert&quot;: {
                &quot;emoji&quot;: &quot;smile&quot;
            }
        },
        {
            &quot;insert&quot;: &quot;this is working...\nfunction getUsers(){
                &quot;
            },
            {
                &quot;attributes&quot;: {
                    &quot;code-block&quot;: &quot;plain&quot;
                },
                &quot;insert&quot;: &quot;\n&quot;
            },
            {
                &quot;insert&quot;: &quot;let x=5;&quot;
            },
            {
                &quot;attributes&quot;: {
                    &quot;code-block&quot;: &quot;plain&quot;
                },
                &quot;insert&quot;: &quot;\n\n&quot;
            },
            {
                &quot;insert&quot;: &quot;if(x===5)&quot;
            },
            {
                &quot;attributes&quot;: {
                    &quot;code-block&quot;: &quot;plain&quot;
                },
                &quot;insert&quot;: &quot;\n&quot;
            },
            {
                &quot;insert&quot;: &quot;displayName();&quot;
            },
            {
                &quot;attributes&quot;: {
                    &quot;code-block&quot;: &quot;plain&quot;
                },
                &quot;insert&quot;: &quot;\n\n&quot;
            },
            {
                &quot;insert&quot;: &quot;return x;&quot;
            },
            {
                &quot;attributes&quot;: {
                    &quot;code-block&quot;: &quot;plain&quot;
                },
                &quot;insert&quot;: &quot;\n&quot;
            },
            {
                &quot;insert&quot;: &quot;
            }&quot;
        },
        {
            &quot;attributes&quot;: {
                &quot;code-block&quot;: &quot;plain&quot;
            },
            &quot;insert&quot;: &quot;\n&quot;
        }
    ]
}</pre>
here is the line
&quot;insert&quot;: &quot;displayName();&quot;
it seems to me that whatever is within the double quotes should be respected
d
What you're dumping is not the raw results of the query. My guess whatever code that is generating the JSON is trimming the value.
a
on the query I have
returntype="struct"
however, I tested with a straight up “query” format.. same thing
d
I don't use Postgres, but perhaps their is DSN option that's trimming values.
a
hmm, I was thinking about that too
just wanted to reach out to make sure its not Lucee
Thanks @dswitzer!!
d
I've definitely not seen that behavior with the MSSQL drivers.
However, we generally do not use the
returnType
attribute on a query, so it's certainly possible that could be adding some logic that I would not see.
a
by default the returntype is set to query. I did try with that as well to no avail
p
Please check the length of the json ( with a slightly smaller json ) using
len( json_from_db )
a
what exactly are you asking me to try?
Instead of printing the json into browser, just check the length of the same using
<cfdump var="#len( stData["1"].json )#" label="length of json string from cfquery" />
a
ok one sec
both are the same length
POST payload length, and query column
p
Is the length matches the actual length of json ?
a
yes
p
So the issue is just because of browser rendering
Not an issue with Lucee
a
yeah, seems to be the case..
thanks for the clever test 🙂
👍 2