Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert() doesn't work with table alias #192

Open
ArthurHoaro opened this issue May 9, 2018 · 0 comments
Open

insert() doesn't work with table alias #192

ArthurHoaro opened this issue May 9, 2018 · 0 comments
Assignees

Comments

@ArthurHoaro
Copy link

ArthurHoaro commented May 9, 2018

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 case
It 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants