{"action":"created","issue":{"url":"https://api.github.com/repos/jmoiron/sqlx/issues/212","repository_url":"https://api.github.com/repos/jmoiron/sqlx","labels_url":"https://api.github.com/repos/jmoiron/sqlx/issues/212/labels{/name}","comments_url":"https://api.github.com/repos/jmoiron/sqlx/issues/212/comments","events_url":"https://api.github.com/repos/jmoiron/sqlx/issues/212/events","html_url":"https://github.com/jmoiron/sqlx/pull/212","id":138615546,"number":212,"title":"Allow multiple tag names","user":{"login":"snikch","id":115958,"avatar_url":"https://avatars.githubusercontent.com/u/115958?v=3","gravatar_id":"","url":"https://api.github.com/users/snikch","html_url":"https://github.com/snikch","followers_url":"https://api.github.com/users/snikch/followers","following_url":"https://api.github.com/users/snikch/following{/other_user}","gists_url":"https://api.github.com/users/snikch/gists{/gist_id}","starred_url":"https://api.github.com/users/snikch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snikch/subscriptions","organizations_url":"https://api.github.com/users/snikch/orgs","repos_url":"https://api.github.com/users/snikch/repos","events_url":"https://api.github.com/users/snikch/events{/privacy}","received_events_url":"https://api.github.com/users/snikch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-04T23:26:19Z","updated_at":"2016-03-04T23:46:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jmoiron/sqlx/pulls/212","html_url":"https://github.com/jmoiron/sqlx/pull/212","diff_url":"https://github.com/jmoiron/sqlx/pull/212.diff","patch_url":"https://github.com/jmoiron/sqlx/pull/212.patch"},"body":"**Note** This PR isn't actually ready for merge since it updates the main package to use my fork\r\n\r\nHey there,\r\n\r\nOne of the use cases that I have for field names is the idea of generally using the `json` tag, but needing to override it on occasion for data that should be retrieved from the db, but not marshalled to json. By adding multiple tag support to `reflectx` I can save myself managing two tags.\r\n\r\nFor example, most of our data is encrypted with a per row nonce. We don't want to expose that nonce, but also don't want to expose the nonce via json. By using `json` tags for most fields, but using the `db` tag when it's available, I can easily provide this functionality.\r\n\r\n```go\r\ntype MyStruct struct {\r\n  Name string `json:\"name\"`\r\n  Nonce string `json:\"-\" db:\"nonce\"`\r\n}\r\n\r\n// My mapper\r\nmyDBClient.Mapper = reflectx.Mapper(\"db\", \"json\")\r\n```\r\n\r\nDoes this seem like something you'd like to support? If so we can talk about the implementation - my current one doesn't support multiple tags when using a mapper func - but a setter could be used to adjust or append to the tag names. It just seemed easiest to add a variadic parameter to the `reflectx.Mapper` function so that the api was backwards compatible."},"comment":{"url":"https://api.github.com/repos/jmoiron/sqlx/issues/comments/192526580","html_url":"https://github.com/jmoiron/sqlx/pull/212#issuecomment-192526580","issue_url":"https://api.github.com/repos/jmoiron/sqlx/issues/212","id":192526580,"user":{"login":"elithrar","id":18544,"avatar_url":"https://avatars.githubusercontent.com/u/18544?v=3","gravatar_id":"","url":"https://api.github.com/users/elithrar","html_url":"https://github.com/elithrar","followers_url":"https://api.github.com/users/elithrar/followers","following_url":"https://api.github.com/users/elithrar/following{/other_user}","gists_url":"https://api.github.com/users/elithrar/gists{/gist_id}","starred_url":"https://api.github.com/users/elithrar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elithrar/subscriptions","organizations_url":"https://api.github.com/users/elithrar/orgs","repos_url":"https://api.github.com/users/elithrar/repos","events_url":"https://api.github.com/users/elithrar/events{/privacy}","received_events_url":"https://api.github.com/users/elithrar/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T23:46:53Z","updated_at":"2016-03-04T23:46:53Z","body":"Note that if you checkout a new branch within your GOPATH, make your\nchanges, and then `go install ./...` you don't have to rewrite the imports.\n\n\nOn Fri, Mar 4, 2016 at 3:26 PM Mal Curtis <notifications@github.com> wrote:\n\n> *Note* This PR isn't actually ready for merge since it updates the main\n> package to use my fork\n>\n> Hey there,\n>\n> One of the use cases that I have for field names is the idea of generally\n> using the json tag, but needing to override it on occasion for data that\n> should be retrieved from the db, but not marshalled to json. By adding\n> multiple tag support to reflectx I can save myself managing two tags.\n>\n> For example, most of our data is encrypted with a per row nonce. We don't\n> want to expose that nonce, but also don't want to expose the nonce via\n> json. By using json tags for most fields, but using the db tag when it's\n> available, I can easily provide this functionality.\n>\n> type MyStruct struct {\n>   Name string `json:\"name\"`\n>   Nonce string `json:\"-\" db:\"nonce\"`\n> }\n> // My mapper\n> myDBClient.Mapper = reflectx.Mapper(\"db\", \"json\")\n>\n> Does this seem like something you'd like to support? If so we can talk\n> about the implementation - my current one doesn't support multiple tags\n> when using a mapper func - but a setter could be used to adjust or append\n> to the tag names. It just seemed easiest to add a variadic parameter to the\n> reflectx.Mapper function so that the api was backwards compatible.\n> ------------------------------\n> You can view, comment on, or merge this pull request online at:\n>\n>   https://github.com/jmoiron/sqlx/pull/212\n> Commit Summary\n>\n>    - Allow fallback tag names\n>\n> File Changes\n>\n>    - *M* bind.go <https://github.com/jmoiron/sqlx/pull/212/files#diff-0>\n>    (2)\n>    - *M* named.go <https://github.com/jmoiron/sqlx/pull/212/files#diff-1>\n>    (2)\n>    - *M* reflectx/reflect.go\n>    <https://github.com/jmoiron/sqlx/pull/212/files#diff-2> (37)\n>    - *M* reflectx/reflect_test.go\n>    <https://github.com/jmoiron/sqlx/pull/212/files#diff-3> (22)\n>    - *M* sqlx.go <https://github.com/jmoiron/sqlx/pull/212/files#diff-4>\n>    (2)\n>\n> Patch Links:\n>\n>    - https://github.com/jmoiron/sqlx/pull/212.patch\n>    - https://github.com/jmoiron/sqlx/pull/212.diff\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/jmoiron/sqlx/pull/212>.\n>\n"}}