{"action":"closed","issue":{"url":"https://api.github.com/repos/go-pg/pg/issues/879","repository_url":"https://api.github.com/repos/go-pg/pg","labels_url":"https://api.github.com/repos/go-pg/pg/issues/879/labels{/name}","comments_url":"https://api.github.com/repos/go-pg/pg/issues/879/comments","events_url":"https://api.github.com/repos/go-pg/pg/issues/879/events","html_url":"https://github.com/go-pg/pg/issues/879","id":329516898,"node_id":"MDU6SXNzdWUzMjk1MTY4OTg=","number":879,"title":"How to override a column in a bulk update?","user":{"login":"jhayotte","id":7420027,"node_id":"MDQ6VXNlcjc0MjAwMjc=","avatar_url":"https://avatars3.githubusercontent.com/u/7420027?v=4","gravatar_id":"","url":"https://api.github.com/users/jhayotte","html_url":"https://github.com/jhayotte","followers_url":"https://api.github.com/users/jhayotte/followers","following_url":"https://api.github.com/users/jhayotte/following{/other_user}","gists_url":"https://api.github.com/users/jhayotte/gists{/gist_id}","starred_url":"https://api.github.com/users/jhayotte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhayotte/subscriptions","organizations_url":"https://api.github.com/users/jhayotte/orgs","repos_url":"https://api.github.com/users/jhayotte/repos","events_url":"https://api.github.com/users/jhayotte/events{/privacy}","received_events_url":"https://api.github.com/users/jhayotte/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-05T15:45:41Z","updated_at":"2018-06-06T10:58:50Z","closed_at":"2018-06-06T10:58:50Z","author_association":"NONE","body":"Hi,\r\n\r\nI have this struct\r\n\r\n```go\r\ntype Article struct {\r\n\tId string `protobuf:\"bytes,1,opt,name=id,proto3\" json:\"id,omitempty\"`\r\n\t// @inject_tag: pg:\",array\" sql:\"type:text[]\"\r\n\tAliases []string `protobuf:\"bytes,3,rep,name=aliases\" json:\"aliases,omitempty\" pg:\",array\" sql:\"type:text[]\"`\r\n\tParentId string `protobuf:\"bytes,4,opt,name=parent_id,json=parentId,proto3\" json:\"parent_id,omitempty\"`\r\n\t// @inject_tag: sql:\"-\"\r\n\tCreationDate *google_protobuf1.Timestamp `protobuf:\"bytes,14,opt,name=creation_date,json=creationDate\" json:\"creation_date,omitempty\" sql:\"-\"`\r\n\t// @inject_tag: sql:\"type:timestamptz,default:now()\"\r\n\tLastUpdate *google_protobuf1.Timestamp `protobuf:\"bytes,15,opt,name=last_update,json=lastUpdate\" json:\"last_update,omitempty\" sql:\"type:timestamptz,default:now()\"`\r\n}\r\n```\r\n\r\n### Override a column for a single entity (no problem)\r\nI need to override the column last_update with value **NOW()** for each operation of type UPDATE. For a single entity, there is no problem, I proceed as below:\r\n\r\n```go\r\ntx.Model(req.Article).Value(\"last_update\", \"NOW()\").Where(\"id = ?\", req.Article.Id)\r\n```\r\n\r\nAnd I get the SQL below:\r\n\r\n```SQL\r\nUPDATE \"articles\" AS \"article\" SET \"aliases\" = NULL, \"parent_id\" = NULL,  \"last_update\" = NOW() WHERE (id = 'd6bfcbf6-68bc-61e8-bd98-00000001522b') \r\n```\r\n\r\n### Override a column for each entity of an array\r\nHowever, when I wish to update an array of Article and override the column last_update with NOW() of each article, I proceed with the same logic:\r\n\r\n```go\r\ntx.Model(&req.Articles).Value(\"last_update\", \"NOW()\").Update()\r\n```\r\nIn the output, the column `last_update` is not overrided. \r\n\r\n```SQL\r\nUPDATE \"articles\" AS \"article\" SET \"aliases\" = _data.\"aliases\", \"parent_id\" = _data.\"parent_id\", \"last_update\" = _data.\"last_update\" FROM (VALUES ('d6bfcbf6-68bc-61e8-bd98-00000001522b',  NULL, '2018-06-05 13:24:00.537503+00:00:00'::timestamptz)) AS _data(\"id\", \"aliases\", \"parent_id\",  \"last_update\") WHERE \"article\".\"id\" = _data.\"id\"\r\n```\r\n\r\nAm I missing something? Is there another way to proceed?\r\n\r\nThanks,\r\n\r\nJulien"}}
{"actor":{"display_login":"vmihailenco"}}