Repository navigation
Commit 1b1a0be
Report the right column name when an INSERT or REPLACE names an unknown column (#634)
Fixes #633.
array_diff() keeps the keys of its first argument, so when the unknown
column is not the first one in the column list, $unknown_columns has no
key 0: PHP warns "Undefined array key 0" and the error says Unknown
column ''. Using reset( $unknown_columns ) reports the first unknown
column, as MySQL does, and adds no work to successful inserts.
Tests: testInsertErrors() and testInsertErrorsInNonStrictMode() now also
cover an unknown column after an existing one, the INSERT ... SET form
and REPLACE. Both fail without the fix ("Undefined array key 0") and
pass with it; the full mysql-on-sqlite suite passes (1822 tests).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Corrected the missing-column name reported for some `INSERT` and
`REPLACE` statements. The error now identifies the first missing column
in the statement, including when valid columns appear before missing
ones. This applies to column-list and `INSERT ... SET` forms, in both
strict and non-strict SQL modes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Jan Jakeš <jan@jakes.pro>1 parent 973810c commit 1b1a0be
2 files changed
Lines changed: 49 additions & 1 deletion
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6144 | 6144 | | |
6145 | 6145 | | |
6146 | 6146 | | |
6147 | | - | |
| 6147 | + | |
6148 | 6148 | | |
6149 | 6149 | | |
6150 | 6150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17695 | 17695 | | |
17696 | 17696 | | |
17697 | 17697 | | |
| 17698 | + | |
| 17699 | + | |
| 17700 | + | |
| 17701 | + | |
| 17702 | + | |
| 17703 | + | |
| 17704 | + | |
| 17705 | + | |
| 17706 | + | |
| 17707 | + | |
| 17708 | + | |
| 17709 | + | |
| 17710 | + | |
| 17711 | + | |
| 17712 | + | |
| 17713 | + | |
| 17714 | + | |
| 17715 | + | |
| 17716 | + | |
| 17717 | + | |
| 17718 | + | |
| 17719 | + | |
| 17720 | + | |
| 17721 | + | |
17698 | 17722 | | |
17699 | 17723 | | |
17700 | 17724 | | |
| |||
17712 | 17736 | | |
17713 | 17737 | | |
17714 | 17738 | | |
| 17739 | + | |
| 17740 | + | |
| 17741 | + | |
| 17742 | + | |
| 17743 | + | |
| 17744 | + | |
| 17745 | + | |
| 17746 | + | |
| 17747 | + | |
| 17748 | + | |
| 17749 | + | |
| 17750 | + | |
| 17751 | + | |
| 17752 | + | |
| 17753 | + | |
| 17754 | + | |
| 17755 | + | |
| 17756 | + | |
| 17757 | + | |
| 17758 | + | |
| 17759 | + | |
| 17760 | + | |
| 17761 | + | |
| 17762 | + | |
17715 | 17763 | | |
17716 | 17764 | | |
17717 | 17765 | | |
| |||
0 commit comments