Open Ushcode opened 1 year ago
Uploaded GeoServer layer after removing comments to bypass issue
The above edit is accepted in the UI and doesn't break the layer
NB Strictly speaking, JSON does not support comments. Indeed some codes that process JSON break if one attempts to put comments in. For that reason, it is best to avoid that altogether...
Do you mean something like
"geoServerSettings": {
"virtualTable": {
"name": "xxx",
"sql": "select yyy from zzz -- comment"
}
}
would cause a problem?
Or a comment within the json itself like a .jsonl one?
A comment within a string in a json file would of course not cause problems for the json itself, but
{
"sql": "@/inputs/config/sql/virtualTables/towers_geoserver.sql", // this is a problem.
}
Ah yes of course. That comment is just there for the example in this issue, not in any real config files
Problem
When a SQL query is specified as a filepath in the
geoServerSettings.virtualTable.sql
node of a data subset in the uploader, adding a comment can cause an issue. This appears to be due to the whole SQL query being flattened to one line, as such comments are still interpreted but anything that comes after them is commented out.N.B. editing the SQL in the GeoServer gui allows for carriage returns to be added again so it does not appear to be necessary to flatten the SQL.
Example
Here is some code and the resultant GeoServer error.
In the config file, a data subset is:
the relevant SQL file:
The result is that GeoServer will not find the columns as it parses the
FROM
clause as commented out.