{"action":"created","issue":{"url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/9","repository_url":"https://api.github.com/repos/turnkey-commerce/gendal","labels_url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/9/comments","events_url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/9/events","html_url":"https://github.com/turnkey-commerce/gendal/pull/9","id":388949044,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3MDg1MDgy","number":9,"title":"Added sqlx compatible flag","user":{"login":"TravisS25","id":5346755,"node_id":"MDQ6VXNlcjUzNDY3NTU=","avatar_url":"https://avatars0.githubusercontent.com/u/5346755?v=4","gravatar_id":"","url":"https://api.github.com/users/TravisS25","html_url":"https://github.com/TravisS25","followers_url":"https://api.github.com/users/TravisS25/followers","following_url":"https://api.github.com/users/TravisS25/following{/other_user}","gists_url":"https://api.github.com/users/TravisS25/gists{/gist_id}","starred_url":"https://api.github.com/users/TravisS25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TravisS25/subscriptions","organizations_url":"https://api.github.com/users/TravisS25/orgs","repos_url":"https://api.github.com/users/TravisS25/repos","events_url":"https://api.github.com/users/TravisS25/events{/privacy}","received_events_url":"https://api.github.com/users/TravisS25/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-08T18:57:17Z","updated_at":"2018-12-09T20:48:55Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/turnkey-commerce/gendal/pulls/9","html_url":"https://github.com/turnkey-commerce/gendal/pull/9","diff_url":"https://github.com/turnkey-commerce/gendal/pull/9.diff","patch_url":"https://github.com/turnkey-commerce/gendal/pull/9.patch"},"body":"Added ability for user to use --sqlx flag when generating from schema to use against the sqlx library http://jmoiron.github.io/sqlx/.  This flag adds the foreign key structs associated with a generated type which allows a user to query and \"follow\" foreign key tables which will be directly translated to structs using the sqlx library.  Along with the added foreign key structs, the template will generate helper functions which will allow user to query database and return with a struct of that type.\r\n\r\nExample:\r\n\r\nCurrently:\r\n```\r\n// Generated code from database\r\n\r\n// user.xo.go\r\ntype User struct{\r\n   ID int \r\n   FirstName string\r\n   LastName string\r\n   Email string\r\n   AddressID int\r\n   PhoneID int\r\n\r\n   _exists, _deleted bool\r\n}\r\n\r\n...\r\n\r\n// address.xo.go\r\ntype Address struct {\r\n   ID int\r\n   Address1 string\r\n   City string\r\n\r\n   _exists, _deleted bool\r\n}\r\n\r\n...\r\n\r\n// phone.xo.go\r\ntype Phone struct {\r\n   ID int\r\n   Number string\r\n\r\n   _exists, _deleted bool\r\n}\r\n...\r\n\r\n```\r\n\r\nWith --sqlx flag:\r\n\r\n```\r\n// Generated code from database\r\n\r\n// user.xo.go\r\ntype User struct{\r\n   ID int \r\n   FirstName string\r\n   LastName string\r\n   Email string\r\n   AddressID int\r\n   PhoneID int\r\n\r\n   _exists, _deleted bool\r\n\r\n   AddressFK *Address `db:\"address\"`\r\n   PhoneFK *Phone `db:\"phone\"`\r\n}\r\n\r\nfunc QueryUser(q sqlx.Queryer, query string, args ...interface{}) (*User, error) {\r\n\tvar dest User\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryUsers(q sqlx.Queryer, query string, args ...interface{}) ([]*User, error) {\r\n\tvar dest []*User\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\nfunc QueryUsersWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) (*User, error) {\r\n\tvar dest User\r\n\terr := sqlx.GetContext(ctx, q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryUsersWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) ([]*User, error) {\r\n\tvar dest []*User\r\n\terr := sqlx.SelectContext(ctx, q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\n...\r\n\r\n// address.xo.go\r\ntype Address struct {\r\n   ID int\r\n   Address1 string\r\n   City string\r\n}\r\n\r\nfunc QueryAddress(q sqlx.Queryer, query string, args ...interface{}) (*Address, error) {\r\n\tvar dest Address\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryAddresses(q sqlx.Queryer, query string, args ...interface{}) ([]*Address, error) {\r\n\tvar dest []*Address\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\nfunc QueryAddressWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) (*Address, error) {\r\n\tvar dest Address\r\n\terr := sqlx.GetContext(ctx, q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryAddressesWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) ([]*Address, error) {\r\n\tvar dest []*Address\r\n\terr := sqlx.SelectContext(ctx, q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\n...\r\n\r\n// phone.xo.go\r\ntype Phone struct {\r\n   ID int\r\n   Number string\r\n}\r\n\r\nfunc QueryPhone(q sqlx.Queryer, query string, args ...interface{}) (*Phone, error) {\r\n\tvar dest Phone\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryPhones(q sqlx.Queryer, query string, args ...interface{}) ([]*Phone, error) {\r\n\tvar dest []*Phone\r\n\terr := sqlx.Get(q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\nfunc QueryPhoneWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) (*Phone, error) {\r\n\tvar dest Phone\r\n\terr := sqlx.GetContext(ctx, q, &dest, query, args...)\r\n\treturn &dest, err\r\n}\r\n\r\nfunc QueryPhonesWithCtx(ctx context.Context, q sqlx.QueryerContext, query string, args ...interface{}) ([]*Phone, error) {\r\n\tvar dest []*Phone\r\n\terr := sqlx.SelectContext(ctx, q, &dest, query, args...)\r\n\treturn dest, err\r\n}\r\n\r\n...\r\n\r\n```\r\n\r\nAs per instructions in contributing.md, I used the tpl.sh to add the modified templates into the binary\r\n  "},"comment":{"url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/comments/445570383","html_url":"https://github.com/turnkey-commerce/gendal/pull/9#issuecomment-445570383","issue_url":"https://api.github.com/repos/turnkey-commerce/gendal/issues/9","id":445570383,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTU3MDM4Mw==","user":{"login":"turnkey-commerce","id":541103,"node_id":"MDQ6VXNlcjU0MTEwMw==","avatar_url":"https://avatars1.githubusercontent.com/u/541103?v=4","gravatar_id":"","url":"https://api.github.com/users/turnkey-commerce","html_url":"https://github.com/turnkey-commerce","followers_url":"https://api.github.com/users/turnkey-commerce/followers","following_url":"https://api.github.com/users/turnkey-commerce/following{/other_user}","gists_url":"https://api.github.com/users/turnkey-commerce/gists{/gist_id}","starred_url":"https://api.github.com/users/turnkey-commerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turnkey-commerce/subscriptions","organizations_url":"https://api.github.com/users/turnkey-commerce/orgs","repos_url":"https://api.github.com/users/turnkey-commerce/repos","events_url":"https://api.github.com/users/turnkey-commerce/events{/privacy}","received_events_url":"https://api.github.com/users/turnkey-commerce/received_events","type":"User","site_admin":false},"created_at":"2018-12-09T20:48:55Z","updated_at":"2018-12-09T20:48:55Z","author_association":"OWNER","body":"Very nice addition, thanks. And good work updating the toml config file as well."}}
{"actor":{"display_login":"turnkey-commerce"}}