select fieldname with space not quoted correct
everyx opened this issue · 0 comments
everyx commented
Bug Report
Q | A |
---|---|
Version(s) | 2.13.4 |
Summary
I want do
"INSERT INTO `news` (`published_on`, `title`, `body`, `summary`, `sort`) SELECT `2021-09-29 20:07:56` AS `published_on`, `Title` AS `title`, `test` AS `body`, `test` AS `summary`, IFNULL(MAX(sort), 0) + 1 AS `sort` FROM `news`"
Current behavior
current sql is
"INSERT INTO `news` (`published_on`, `title`, `body`, `summary`, `sort`) SELECT `2021-09-29` `20:07:56` AS `published_on`, `Title` AS `title`, `test` AS `body`, `test` AS `summary`, IFNULL(MAX(sort), 0) + 1 AS `sort` FROM `news`"
How to reproduce
$data = [
"published_on":"2021-09-29 20:07:56",
"title":"Title",
"body":"test",
"summary":"test"
"sort": new Expression("IFNULL(MAX($sortingFieldName), 0) + 1")
];
$select = new Select();
$select->from('news')->columns($data, false);
$insert = new Insert();
$columns = array_keys($data);
$insert->into('news')->columns($columns)->values($select);
echo new Sql($this->adapter, 'news');->buildSqlString($insert);
Expected behavior
use
`2021-09-29 20:07:56` AS `published_on`
not
`2021-09-29` `20:07:56` AS `published_on`