With an alias associated to a table, the insert query will use the table alias instead of its actual name.
How to reproduce
// Call this with an open DB connection
QB::table(['table' => 't'])->insert(['data' => 33]);
Actual result (MySQL)
PHP Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'schema.t' doesn't exist
with generated SQL
INSERT INTO `t` (`data`) VALUES (?)
Expected result
The full « table » name is used in the INSERT INTO query, such as:
INSERT INTO `table` (`data`) VALUES (?)
Use caseIt also affects updateOrInsert(), which is a great helper that can be used on complex queries, where table aliases are really convenient.
Sorry, my use case is wrong, updateOrInsert() doesn't support joins, I don't know why I thought it would have. So this issue doesn't really matter, but it still feels like it should be addressed, for consistency.
With an alias associated to a table, the insert query will use the table alias instead of its actual name.
How to reproduce
Actual result (MySQL)
with generated SQL
Expected result The full « table » name is used in the
INSERT INTO
query, such as:Use case
It also affectsSorry, my use case is wrong,updateOrInsert()
, which is a great helper that can be used on complex queries, where table aliases are really convenient.updateOrInsert()
doesn't support joins, I don't know why I thought it would have. So this issue doesn't really matter, but it still feels like it should be addressed, for consistency.