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

select fieldname with space not quoted correct #225

Open
everyx opened this issue Oct 6, 2021 · 0 comments
Open

select fieldname with space not quoted correct #225

everyx opened this issue Oct 6, 2021 · 0 comments
Labels
Bug Something isn't working

Comments

@everyx
Copy link

everyx commented Oct 6, 2021

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` 

I found some related issues: #84 and #146

@everyx everyx added the Bug Something isn't working label Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant