[#2930] added extra normalizations to ensure that newly created multiple fields has the correct zero-default for already inserted records

This commit is contained in:
Gani Georgiev
2023-07-17 11:38:19 +03:00
parent b9993aaa73
commit 94a1cc07d5
38 changed files with 200 additions and 160 deletions

View File

@@ -580,8 +580,8 @@ func (r *runner) processActiveProps() (*search.ResolverResult, error) {
func jsonArrayLength(tableColumnPair string) string {
return fmt.Sprintf(
// note: the case is used to normalize value access for single and multiple relations.
`json_array_length(CASE WHEN json_valid([[%s]]) THEN [[%s]] ELSE json_array([[%s]]) END)`,
tableColumnPair, tableColumnPair, tableColumnPair,
`json_array_length(CASE WHEN json_valid([[%s]]) THEN [[%s]] ELSE (CASE WHEN [[%s]] = '' OR [[%s]] IS NULL THEN json_array() ELSE json_array([[%s]]) END) END)`,
tableColumnPair, tableColumnPair, tableColumnPair, tableColumnPair, tableColumnPair,
)
}