Commit 0a764ce
Fix enum 0 value validation to respect STRICT_TRANS_TABLES mode
Previously, enum columns would always reject 0 values and other invalid
values with ErrConvertingToEnum, regardless of SQL mode. This change
implements proper MySQL-compatible behavior:
- In STRICT_TRANS_TABLES mode: Invalid enum values (including 0) return
ErrDataTruncatedForColumn error
- In non-strict mode: Invalid enum values are converted to empty string
(index 0)
- INSERT IGNORE: Now properly handles ErrDataTruncatedForColumn as an
ignorable error, converting invalid values to empty string with warnings
Changes made:
- Modified EnumType.Convert() to check SQL mode and handle invalid values
accordingly
- Added special handling for integer 0 in strict mode
- Ensured uint16(0) is always allowed as internal enum storage value
- Added ErrDataTruncatedForColumn to IgnorableErrors list for INSERT IGNORE
- Updated unit tests to reflect correct MySQL-compatible behavior
- Added integration tests for enum zero validation in both strict and
non-strict modes
Fixes dolthub/dolt#9425
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 1af0f6e commit 0a764ce
File tree
4 files changed
+70
-4
lines changed- enginetest/queries
- sql
- plan
- types
4 files changed
+70
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2836 | 2836 | | |
2837 | 2837 | | |
2838 | 2838 | | |
2839 | | - | |
| 2839 | + | |
2840 | 2840 | | |
2841 | 2841 | | |
2842 | 2842 | | |
| |||
2849 | 2849 | | |
2850 | 2850 | | |
2851 | 2851 | | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
2852 | 2889 | | |
2853 | 2890 | | |
2854 | 2891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
168 | 177 | | |
169 | 178 | | |
170 | 179 | | |
| |||
176 | 185 | | |
177 | 186 | | |
178 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
179 | 192 | | |
180 | 193 | | |
181 | 194 | | |
| |||
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
207 | 233 | | |
208 | 234 | | |
209 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
0 commit comments