Thanks for reporting an issue! Spend 60 seconds reading this…
======== TEMPLATE BUG FORM ========
Wappler Version : 3.7.4
Operating System : Windows 10
Server Model: NodeJS
Database Type: PostgreSQL
Hosting Type: Docker
BUG ISSUE
This is a strange issue and i have tried to document it a best as possible:
Issues:
When using the dateAdd
function on a setValue
in Server Connect the output is modifying the actual output data in the actual SQL query itself, and any other value related to that query.
Here is a simple query in Wappler:
And here is the actual query:
And here is the output in Mozilla/Chome
{"summary":{"id":39,"date_start":"2021-02-08T00:00:00.000Z"}}
So now to demonstrate the issue, I add two different setValue
steps to the server connect file.
First, they will just set the value of the date as is without any modification:
Here is the result:
{
"summary": {
"id": 39,
"date_start": "2021-02-08T00:00:00.000Z"
},
"date": "2021-02-08T00:00:00.000Z",
"datePlusOneDay": "2021-02-08T00:00:00.000Z"
}
As you can see, all is working as expected, the two values are showing the same value as what is in the query result.
Now, i will use the dateAdd
formatter to modify the second value called datePlusOneDay
And here is the result. You will see that all three occurrences of the date have changed by one day. INCLUDING the output from the actual SQL query.
{
"summary": {
"id": 39,
"date_start": "2021-02-09T00:00:00.000Z"
},
"date": "2021-02-09T00:00:00.000Z",
"datePlusOneDay": "2021-02-09T00:00:00.000Z"
}
I don’t know how this is possible. I have tested this in so many different ways and in new server connect files. This issue is causing problems for me and is preventing certain loops/functions from working properly.
I have also included a the full file details below:
{
"meta": {
"$_GET": [
{
"type": "text",
"name": "work_group_id"
},
{
"type": "text",
"name": "forecast_id"
}
]
},
"exec": {
"steps": [
{
"name": "summary",
"module": "dbconnector",
"action": "single",
"options": {
"connection": "db",
"sql": {
"type": "SELECT",
"columns": [
{
"table": "forecasts",
"column": "id"
},
{
"table": "forecasts",
"column": "date_start"
}
],
"table": {
"name": "forecasts"
},
"joins": [],
"wheres": {
"condition": "AND",
"rules": [
{
"id": "forecasts.id",
"field": "forecasts.id",
"type": "double",
"operator": "equal",
"value": 39,
"data": {
"table": "forecasts",
"column": "id",
"type": "number"
},
"operation": "="
}
],
"conditional": null,
"valid": true
},
"query": "SELECT id, date_start\nFROM forecasts\nWHERE id = 39",
"params": []
}
},
"output": true,
"meta": [
{
"name": "id",
"type": "text"
},
{
"name": "date_start",
"type": "text"
}
],
"outputType": "object"
},
{
"name": "date",
"module": "core",
"action": "setvalue",
"options": {
"value": "{{summary.date_start}}"
},
"output": true,
"outputType": "date"
},
{
"name": "datePlusOneDay",
"module": "core",
"action": "setvalue",
"options": {
"value": "{{summary.date_start.dateAdd('days', 1)}}"
},
"output": true,
"outputType": "date"
}
]
}
}