Commit a2d1d7c
authored
test: add failing test for cond/if calculation in query filters (#766)
cond/if expressions used in query filters produce a
DBConnection.EncodeError because the THEN clause literals in the
generated CASE WHEN are not type-cast (e.g. THEN 3) when the
expression appears in a WHERE clause, while they ARE properly cast
(e.g. THEN 3::bigint) in a SELECT clause.
The root cause is in ash_sql's expr.ex: when embedded? is true
(which it is for cond/if expression nodes), the literal handler
at default_dynamic_expr/6 skips type casting entirely, so the
Fragment parameters end up as {value, :any}. Postgrex then cannot
infer the correct encoding from context and defaults to text,
causing the binary vs integer mismatch.1 parent b456c85 commit a2d1d7c
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1100 | 1100 | | |
1101 | 1101 | | |
1102 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
1103 | 1128 | | |
1104 | 1129 | | |
1105 | 1130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1124 | 1124 | | |
1125 | 1125 | | |
1126 | 1126 | | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
1127 | 1141 | | |
1128 | 1142 | | |
1129 | 1143 | | |
| |||
0 commit comments