{"action":"created","issue":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/679","repository_url":"https://api.github.com/repos/typeorm/typeorm","labels_url":"https://api.github.com/repos/typeorm/typeorm/issues/679/labels{/name}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/679/comments","events_url":"https://api.github.com/repos/typeorm/typeorm/issues/679/events","html_url":"https://github.com/typeorm/typeorm/issues/679","id":243583038,"node_id":"MDU6SXNzdWUyNDM1ODMwMzg=","number":679,"title":"Question on update query","user":{"login":"jjude","id":2066505,"node_id":"MDQ6VXNlcjIwNjY1MDU=","avatar_url":"https://avatars0.githubusercontent.com/u/2066505?v=4","gravatar_id":"","url":"https://api.github.com/users/jjude","html_url":"https://github.com/jjude","followers_url":"https://api.github.com/users/jjude/followers","following_url":"https://api.github.com/users/jjude/following{/other_user}","gists_url":"https://api.github.com/users/jjude/gists{/gist_id}","starred_url":"https://api.github.com/users/jjude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjude/subscriptions","organizations_url":"https://api.github.com/users/jjude/orgs","repos_url":"https://api.github.com/users/jjude/repos","events_url":"https://api.github.com/users/jjude/events{/privacy}","received_events_url":"https://api.github.com/users/jjude/received_events","type":"User","site_admin":false},"labels":[{"id":333605715,"node_id":"MDU6TGFiZWwzMzM2MDU3MTU=","url":"https://api.github.com/repos/typeorm/typeorm/labels/invalid","name":"invalid","color":"e6e6e6","default":true},{"id":333605716,"node_id":"MDU6TGFiZWwzMzM2MDU3MTY=","url":"https://api.github.com/repos/typeorm/typeorm/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-18T02:38:31Z","updated_at":"2018-06-18T08:08:49Z","closed_at":"2017-07-28T07:47:40Z","author_association":"NONE","body":"May be this has to do with my understanding of Javascript. Still let me ask.\r\n\r\n```\r\nconst siteDetails = {name:\"hello\", type:1};\r\n\r\nconst result = await dbConnection\r\n      .getRepository(Site)\r\n      .createQueryBuilder(\"site\")\r\n      .update(siteDetails)\r\n      .where(\"site.id = :siteId and site.owner = :ownerId\", { siteId, ownerId: userId })\r\n      .execute();\r\n```\r\n\r\nThis raises the following error:\r\n\r\n```\r\nCannot perform update query because update values are not defined. Call \"qb.set(...)\" method to specify inserted values.\r\n```\r\nHowever, if I do \r\n\r\n```\r\nconst result = await dbConnection\r\n      .getRepository(Site)\r\n      .createQueryBuilder(\"site\")\r\n      .update({name:\"hello\", type:1})\r\n      .where(\"site.id = :siteId and site.owner = :ownerId\", { siteId, ownerId: userId })\r\n      .execute();\r\n```\r\n\r\nit works. How do I pass update values in a variable?"},"comment":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/comments/397974558","html_url":"https://github.com/typeorm/typeorm/issues/679#issuecomment-397974558","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/679","id":397974558,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Nzk3NDU1OA==","user":{"login":"peterhoneder","id":22821051,"node_id":"MDQ6VXNlcjIyODIxMDUx","avatar_url":"https://avatars1.githubusercontent.com/u/22821051?v=4","gravatar_id":"","url":"https://api.github.com/users/peterhoneder","html_url":"https://github.com/peterhoneder","followers_url":"https://api.github.com/users/peterhoneder/followers","following_url":"https://api.github.com/users/peterhoneder/following{/other_user}","gists_url":"https://api.github.com/users/peterhoneder/gists{/gist_id}","starred_url":"https://api.github.com/users/peterhoneder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterhoneder/subscriptions","organizations_url":"https://api.github.com/users/peterhoneder/orgs","repos_url":"https://api.github.com/users/peterhoneder/repos","events_url":"https://api.github.com/users/peterhoneder/events{/privacy}","received_events_url":"https://api.github.com/users/peterhoneder/received_events","type":"User","site_admin":false},"created_at":"2018-06-18T08:08:49Z","updated_at":"2018-06-18T08:08:49Z","author_association":"NONE","body":"just one note where just this error can come along: the object passed in to set() or something similar in query builder to set the attributes to be updated in update or inserted in insert needs to be instanceof Object. In my case graphql objects returned from apollo server where not instanceof Object, which makes passing them directly on to TypeORM fail (you can Object.assign them e.g. to solve it)."}}
{"actor":{"display_login":"peterhoneder"}}