{"action":"created","comment":{"url":"https://api.github.com/repos/dancannon/gorethink/pulls/comments/74983102","id":74983102,"diff_hunk":"@@ -485,34 +485,56 @@ type mapAsStructDecoder struct {\n func (d *mapAsStructDecoder) decode(dv, sv reflect.Value) {\n \tfor _, kv := range sv.MapKeys() {\n \t\tvar f *field\n+\t\tvar compoundFields = []*field{}\n \t\tvar fieldDec decoderFunc\n \t\tkey := []byte(kv.String())\n \t\tfor i := range d.fields {\n \t\t\tff := &d.fields[i]\n \t\t\tffd := d.fieldDecs[i]\n+\n \t\t\tif bytes.Equal(ff.nameBytes, key) {\n \t\t\t\tf = ff\n \t\t\t\tfieldDec = ffd\n-\t\t\t\tbreak\n \t\t\t}\n \t\t\tif f == nil && ff.equalFold(ff.nameBytes, key) {\n \t\t\t\tf = ff\n \t\t\t\tfieldDec = ffd\n \t\t\t}\n-\t\t}\n \n-\t\tif f == nil {\n-\t\t\tcontinue\n+\t\t\tif f != nil && f.compound {\n+\t\t\t\tcompoundFields = append(compoundFields, f)\n+\t\t\t} else if f != nil {\n+\t\t\t\tbreak\n+\t\t\t}\n \t\t}\n \n-\t\tdElemVal := fieldByIndex(dv, f.index)\n-\t\tsElemVal := sv.MapIndex(kv)\n+\t\tif len(compoundFields) > 0 {","path":"encoding/decoder_types.go","position":33,"original_position":33,"commit_id":"bbd3f2b9f74cf3a3ee244ff74e0fef0a9e158f15","original_commit_id":"bbd3f2b9f74cf3a3ee244ff74e0fef0a9e158f15","user":{"login":"tve","id":39480,"avatar_url":"https://avatars.githubusercontent.com/u/39480?v=3","gravatar_id":"","url":"https://api.github.com/users/tve","html_url":"https://github.com/tve","followers_url":"https://api.github.com/users/tve/followers","following_url":"https://api.github.com/users/tve/following{/other_user}","gists_url":"https://api.github.com/users/tve/gists{/gist_id}","starred_url":"https://api.github.com/users/tve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tve/subscriptions","organizations_url":"https://api.github.com/users/tve/orgs","repos_url":"https://api.github.com/users/tve/repos","events_url":"https://api.github.com/users/tve/events{/privacy}","received_events_url":"https://api.github.com/users/tve/received_events","type":"User","site_admin":false},"body":"I believe this says that a field in the DB can either be mapped to/from one field in the Go struct or to multiple fields using the compound key syntax, but you can mix the two. Which makes sense. Might be nice to state it explicitly in the docs?","created_at":"2016-08-16T17:40:22Z","updated_at":"2016-08-16T17:40:22Z","html_url":"https://github.com/dancannon/gorethink/pull/358#discussion_r74983102","pull_request_url":"https://api.github.com/repos/dancannon/gorethink/pulls/358","_links":{"self":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/comments/74983102"},"html":{"href":"https://github.com/dancannon/gorethink/pull/358#discussion_r74983102"},"pull_request":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/358"}}},"pull_request":{"url":"https://api.github.com/repos/dancannon/gorethink/pulls/358","id":80714137,"html_url":"https://github.com/dancannon/gorethink/pull/358","diff_url":"https://github.com/dancannon/gorethink/pull/358.diff","patch_url":"https://github.com/dancannon/gorethink/pull/358.patch","issue_url":"https://api.github.com/repos/dancannon/gorethink/issues/358","number":358,"state":"open","locked":false,"title":"Add ability to create compound key using struct tags","user":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"body":"As suggested in #342 this PR adds the ability to create compound keys using struct tags. If a struct tag includes an index expression then the driver creates and array of fields when encoding and then attempts to decode this array back when decoding.","created_at":"2016-08-09T23:49:55Z","updated_at":"2016-08-16T17:40:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d963d2a4ec237ad94b77c11dfe60054b930a57a","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dancannon/gorethink/milestones/10","html_url":"https://github.com/dancannon/gorethink/milestones/v2.2.0","labels_url":"https://api.github.com/repos/dancannon/gorethink/milestones/10/labels","id":1924311,"number":10,"title":"v2.2.0","description":"","creator":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":2,"state":"open","created_at":"2016-08-04T20:38:26Z","updated_at":"2016-08-15T21:06:18Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dancannon/gorethink/pulls/358/commits","review_comments_url":"https://api.github.com/repos/dancannon/gorethink/pulls/358/comments","review_comment_url":"https://api.github.com/repos/dancannon/gorethink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dancannon/gorethink/issues/358/comments","statuses_url":"https://api.github.com/repos/dancannon/gorethink/statuses/bbd3f2b9f74cf3a3ee244ff74e0fef0a9e158f15","head":{"label":"dancannon:feature/compound-keys","ref":"feature/compound-keys","sha":"bbd3f2b9f74cf3a3ee244ff74e0fef0a9e158f15","user":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"repo":{"id":12785038,"name":"gorethink","full_name":"dancannon/gorethink","owner":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dancannon/gorethink","description":"Go language driver for RethinkDB","fork":false,"url":"https://api.github.com/repos/dancannon/gorethink","forks_url":"https://api.github.com/repos/dancannon/gorethink/forks","keys_url":"https://api.github.com/repos/dancannon/gorethink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dancannon/gorethink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dancannon/gorethink/teams","hooks_url":"https://api.github.com/repos/dancannon/gorethink/hooks","issue_events_url":"https://api.github.com/repos/dancannon/gorethink/issues/events{/number}","events_url":"https://api.github.com/repos/dancannon/gorethink/events","assignees_url":"https://api.github.com/repos/dancannon/gorethink/assignees{/user}","branches_url":"https://api.github.com/repos/dancannon/gorethink/branches{/branch}","tags_url":"https://api.github.com/repos/dancannon/gorethink/tags","blobs_url":"https://api.github.com/repos/dancannon/gorethink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dancannon/gorethink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dancannon/gorethink/git/refs{/sha}","trees_url":"https://api.github.com/repos/dancannon/gorethink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dancannon/gorethink/statuses/{sha}","languages_url":"https://api.github.com/repos/dancannon/gorethink/languages","stargazers_url":"https://api.github.com/repos/dancannon/gorethink/stargazers","contributors_url":"https://api.github.com/repos/dancannon/gorethink/contributors","subscribers_url":"https://api.github.com/repos/dancannon/gorethink/subscribers","subscription_url":"https://api.github.com/repos/dancannon/gorethink/subscription","commits_url":"https://api.github.com/repos/dancannon/gorethink/commits{/sha}","git_commits_url":"https://api.github.com/repos/dancannon/gorethink/git/commits{/sha}","comments_url":"https://api.github.com/repos/dancannon/gorethink/comments{/number}","issue_comment_url":"https://api.github.com/repos/dancannon/gorethink/issues/comments{/number}","contents_url":"https://api.github.com/repos/dancannon/gorethink/contents/{+path}","compare_url":"https://api.github.com/repos/dancannon/gorethink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dancannon/gorethink/merges","archive_url":"https://api.github.com/repos/dancannon/gorethink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dancannon/gorethink/downloads","issues_url":"https://api.github.com/repos/dancannon/gorethink/issues{/number}","pulls_url":"https://api.github.com/repos/dancannon/gorethink/pulls{/number}","milestones_url":"https://api.github.com/repos/dancannon/gorethink/milestones{/number}","notifications_url":"https://api.github.com/repos/dancannon/gorethink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dancannon/gorethink/labels{/name}","releases_url":"https://api.github.com/repos/dancannon/gorethink/releases{/id}","deployments_url":"https://api.github.com/repos/dancannon/gorethink/deployments","created_at":"2013-09-12T13:56:27Z","updated_at":"2016-08-15T09:34:20Z","pushed_at":"2016-08-15T22:11:56Z","git_url":"git://github.com/dancannon/gorethink.git","ssh_url":"git@github.com:dancannon/gorethink.git","clone_url":"https://github.com/dancannon/gorethink.git","svn_url":"https://github.com/dancannon/gorethink","homepage":"","size":2226,"stargazers_count":1001,"watchers_count":1001,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":13,"forks":103,"open_issues":13,"watchers":1001,"default_branch":"master"}},"base":{"label":"dancannon:develop","ref":"develop","sha":"4eaf833b7be878513a658d54d475698e9afce28f","user":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"repo":{"id":12785038,"name":"gorethink","full_name":"dancannon/gorethink","owner":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dancannon/gorethink","description":"Go language driver for RethinkDB","fork":false,"url":"https://api.github.com/repos/dancannon/gorethink","forks_url":"https://api.github.com/repos/dancannon/gorethink/forks","keys_url":"https://api.github.com/repos/dancannon/gorethink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dancannon/gorethink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dancannon/gorethink/teams","hooks_url":"https://api.github.com/repos/dancannon/gorethink/hooks","issue_events_url":"https://api.github.com/repos/dancannon/gorethink/issues/events{/number}","events_url":"https://api.github.com/repos/dancannon/gorethink/events","assignees_url":"https://api.github.com/repos/dancannon/gorethink/assignees{/user}","branches_url":"https://api.github.com/repos/dancannon/gorethink/branches{/branch}","tags_url":"https://api.github.com/repos/dancannon/gorethink/tags","blobs_url":"https://api.github.com/repos/dancannon/gorethink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dancannon/gorethink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dancannon/gorethink/git/refs{/sha}","trees_url":"https://api.github.com/repos/dancannon/gorethink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dancannon/gorethink/statuses/{sha}","languages_url":"https://api.github.com/repos/dancannon/gorethink/languages","stargazers_url":"https://api.github.com/repos/dancannon/gorethink/stargazers","contributors_url":"https://api.github.com/repos/dancannon/gorethink/contributors","subscribers_url":"https://api.github.com/repos/dancannon/gorethink/subscribers","subscription_url":"https://api.github.com/repos/dancannon/gorethink/subscription","commits_url":"https://api.github.com/repos/dancannon/gorethink/commits{/sha}","git_commits_url":"https://api.github.com/repos/dancannon/gorethink/git/commits{/sha}","comments_url":"https://api.github.com/repos/dancannon/gorethink/comments{/number}","issue_comment_url":"https://api.github.com/repos/dancannon/gorethink/issues/comments{/number}","contents_url":"https://api.github.com/repos/dancannon/gorethink/contents/{+path}","compare_url":"https://api.github.com/repos/dancannon/gorethink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dancannon/gorethink/merges","archive_url":"https://api.github.com/repos/dancannon/gorethink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dancannon/gorethink/downloads","issues_url":"https://api.github.com/repos/dancannon/gorethink/issues{/number}","pulls_url":"https://api.github.com/repos/dancannon/gorethink/pulls{/number}","milestones_url":"https://api.github.com/repos/dancannon/gorethink/milestones{/number}","notifications_url":"https://api.github.com/repos/dancannon/gorethink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dancannon/gorethink/labels{/name}","releases_url":"https://api.github.com/repos/dancannon/gorethink/releases{/id}","deployments_url":"https://api.github.com/repos/dancannon/gorethink/deployments","created_at":"2013-09-12T13:56:27Z","updated_at":"2016-08-15T09:34:20Z","pushed_at":"2016-08-15T22:11:56Z","git_url":"git://github.com/dancannon/gorethink.git","ssh_url":"git@github.com:dancannon/gorethink.git","clone_url":"https://github.com/dancannon/gorethink.git","svn_url":"https://github.com/dancannon/gorethink","homepage":"","size":2226,"stargazers_count":1001,"watchers_count":1001,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":13,"forks":103,"open_issues":13,"watchers":1001,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/358"},"html":{"href":"https://github.com/dancannon/gorethink/pull/358"},"issue":{"href":"https://api.github.com/repos/dancannon/gorethink/issues/358"},"comments":{"href":"https://api.github.com/repos/dancannon/gorethink/issues/358/comments"},"review_comments":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/358/comments"},"review_comment":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dancannon/gorethink/pulls/358/commits"},"statuses":{"href":"https://api.github.com/repos/dancannon/gorethink/statuses/bbd3f2b9f74cf3a3ee244ff74e0fef0a9e158f15"}}}}
{"actor":{"display_login":"tve"}}