cerberus-core
cerberus-core copied to clipboard
Null Values in Cerberus
Hello,
Currently null values from an SQL datalib are considered as string and returned with this format :
[
{
dividedOpens: "<NULL>",
dividedCloses: "<NULL>",
opens: "<NULL>",
closes: "<NULL>"
}
]
As Json API Standard advise could, you change the format of thoses null values in response ?
[
{
dividedOpens: null,
dividedCloses: null,
opens: null,
closes: "null
}
]
The aim of this issue is to compare null values without any conversion needed
By default in JAVA putting a null string into a JSONObject do not generate any entry on the final JSON Object. Why don't you test the string or text = <NULL> in order to confirm what is null ? In other wors what use case do you try to solve ? I guess a control but which control with which values ?
I compare information from DB and from an API. Depending on the property, this property can be 'null' or associated to an other value.
The control is 'verifyTextInElement' with a jsonPath that returns me 'null'. The DB control returns me "<NULL>"
.
In this example, I have to reworked the "<NULL>"
with an intermediate property :
getFromGroovy :
def hour = "%property.workingHourSaturday.closes%";
hour.replaceAll("<","").replaceAll(">","")
so I can the following result :
Element '$.data[6].attributes.opens' with value 'null' is equal to 'NULL' with case sensitive constraint : ''.
What about adding a parameter in order to defined and tune the value you wnt to use of null SQL values ?
Yes that is something that could work.
Do you think this change would not be wanted by the majority of Cerberus users ? It seems that comparing elements depending on the type is often used in api testing.