{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/11242","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/11242/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11242/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/11242/events","html_url":"https://github.com/yiisoft/yii2/issues/11242","id":144813715,"number":11242,"title":"batchInsert incorrectly quotes SQL query with values, containing {{ }} symbols","user":{"login":"mutyonok","id":87682,"avatar_url":"https://avatars.githubusercontent.com/u/87682?v=3","gravatar_id":"","url":"https://api.github.com/users/mutyonok","html_url":"https://github.com/mutyonok","followers_url":"https://api.github.com/users/mutyonok/followers","following_url":"https://api.github.com/users/mutyonok/following{/other_user}","gists_url":"https://api.github.com/users/mutyonok/gists{/gist_id}","starred_url":"https://api.github.com/users/mutyonok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mutyonok/subscriptions","organizations_url":"https://api.github.com/users/mutyonok/orgs","repos_url":"https://api.github.com/users/mutyonok/repos","events_url":"https://api.github.com/users/mutyonok/events{/privacy}","received_events_url":"https://api.github.com/users/mutyonok/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-31T07:31:29Z","updated_at":"2016-03-31T10:40:11Z","closed_at":"2016-03-31T08:45:29Z","body":"### What steps will reproduce the problem?\r\n`$this->db->createCommand()->batchInsert('table', ['column1'], [[\"input-{{value}}\"]])->execute();`\r\n\r\n### What is the expected result?\r\nValue inserted into a table\r\n### What do you get instead?\r\n[yii\\db\\Exception] SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax\r\nThe SQL being executed was: `INSERT INTO \"table\" (\"column1\") VALUES ('input-\"value\"')`\r\n\r\n### Additional info\r\nThe problem is that `Command::setSql` method quotes already prepared batch insert query with `'/(\\\\{\\\\{(%?[\\w\\-\\. ]+%?)\\\\}\\\\}|\\\\[\\\\[([\\w\\-\\. ]+)\\\\]\\\\])/'` regexp inside `Connection::quoteSql` which does not know anything about the context \r\n \r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | Yii v2.0.7\r\n| PHP version      | PHP 5.6.16 (cli) (built: Nov 27 2015 10:28:34) \r\n| Operating system | Any\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/203874156","html_url":"https://github.com/yiisoft/yii2/issues/11242#issuecomment-203874156","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/11242","id":203874156,"user":{"login":"mutyonok","id":87682,"avatar_url":"https://avatars.githubusercontent.com/u/87682?v=3","gravatar_id":"","url":"https://api.github.com/users/mutyonok","html_url":"https://github.com/mutyonok","followers_url":"https://api.github.com/users/mutyonok/followers","following_url":"https://api.github.com/users/mutyonok/following{/other_user}","gists_url":"https://api.github.com/users/mutyonok/gists{/gist_id}","starred_url":"https://api.github.com/users/mutyonok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mutyonok/subscriptions","organizations_url":"https://api.github.com/users/mutyonok/orgs","repos_url":"https://api.github.com/users/mutyonok/repos","events_url":"https://api.github.com/users/mutyonok/events{/privacy}","received_events_url":"https://api.github.com/users/mutyonok/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T10:40:11Z","updated_at":"2016-03-31T10:40:11Z","body":"the problem is only in batchInsert method, because it quotes SQL after a query is already built.\r\nYou have table name and columns as parameters of a batchInsert method - just quote them, not the whole query."}}