{"action":"closed","issue":{"url":"https://api.github.com/repos/marshmallow-code/marshmallow-sqlalchemy/issues/36","labels_url":"https://api.github.com/repos/marshmallow-code/marshmallow-sqlalchemy/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/marshmallow-code/marshmallow-sqlalchemy/issues/36/comments","events_url":"https://api.github.com/repos/marshmallow-code/marshmallow-sqlalchemy/issues/36/events","html_url":"https://github.com/marshmallow-code/marshmallow-sqlalchemy/issues/36","id":111273367,"number":36,"title":"ModelSchema default behaviour needs a lot of overriding","user":{"login":"paj28","id":1894877,"avatar_url":"https://avatars.githubusercontent.com/u/1894877?v=3","gravatar_id":"","url":"https://api.github.com/users/paj28","html_url":"https://github.com/paj28","followers_url":"https://api.github.com/users/paj28/followers","following_url":"https://api.github.com/users/paj28/following{/other_user}","gists_url":"https://api.github.com/users/paj28/gists{/gist_id}","starred_url":"https://api.github.com/users/paj28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paj28/subscriptions","organizations_url":"https://api.github.com/users/paj28/orgs","repos_url":"https://api.github.com/users/paj28/repos","events_url":"https://api.github.com/users/paj28/events{/privacy}","received_events_url":"https://api.github.com/users/paj28/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-13T21:19:37Z","updated_at":"2015-10-26T22:07:20Z","closed_at":"2015-10-26T22:07:20Z","body":"The current behaviour of ModelSchema is not that useful to me. Where I have, say, an \"order\" many-to-one relationship, by default it dumps a field \"order\" with the order_id, and this serialised data does not then load. It would be more helpful to dump this as field \"order_id\". one-to-many relationships are similarly not that useful. \r\n\r\nRight now I am using a lot of excludes and manually defined fields, but this is unnecessary. In fact, marshmallow-sqlalchemy already has much more helpful default logic, on TableSchema, especially with include_fk=True. I can't directly use TableSchema as it only supports dump and I also need to load.\r\n\r\nHowever, a one line change to schema.py really helps:\r\n\r\n```\r\nreturn converter.fields_for_model(opts.model, fields=opts.fields, exclude=opts.exclude)\r\n-->\r\nreturn converter.fields_for_table(opts.model.__table__, include_fk=True, fields=opts.fields, exclude=opts.exclude)\r\n```\r\n\r\nI realise this would break compatibility, but it seems a much more helpful default to me."}}