{"action":"created","comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/comments/40031870","id":40031870,"diff_hunk":"@@ -1902,13 +1898,13 @@ public function belongsToComponent($component, $classOnly = true) {\n \t}\n \n \t/**\n-\t * Return all of the database fields defined in self::$db and all the parent classes.\n-\t * Doesn't include any fields specified by self::$has_one.  Use $this->hasOne() to get these fields\n+\t * Return all of the database fields in this object\n \t *\n \t * @param string $fieldName Limit the output to a specific field name\n+\t * @param string $table Out parameter of the table this db field is set to\n \t * @return array The database fields\n \t */\n-\tpublic function db($fieldName = null) {\n+\tpublic function db($fieldName = null, &$table = null) {","path":"model/DataObject.php","position":504,"original_position":504,"commit_id":"e25ffab6bca2f7091a07e2efb31c2d5987ace17a","original_commit_id":"e25ffab6bca2f7091a07e2efb31c2d5987ace17a","user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"body":"I could change the return type to be `Table.Column(spec)` format instead of `Column(spec)`. :)","created_at":"2015-09-21T21:57:32Z","updated_at":"2015-09-21T21:57:32Z","html_url":"https://github.com/silverstripe/silverstripe-framework/pull/4590#discussion_r40031870","pull_request_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590","_links":{"self":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/comments/40031870"},"html":{"href":"https://github.com/silverstripe/silverstripe-framework/pull/4590#discussion_r40031870"},"pull_request":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590"}}},"pull_request":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590","id":44386993,"html_url":"https://github.com/silverstripe/silverstripe-framework/pull/4590","diff_url":"https://github.com/silverstripe/silverstripe-framework/pull/4590.diff","patch_url":"https://github.com/silverstripe/silverstripe-framework/pull/4590.patch","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/4590","number":4590,"state":"open","locked":false,"title":"API Refactor CompositeDBField into an abstract class","user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"body":"Adapted from https://github.com/silverstripe/silverstripe-framework/pull/4583\r\n\r\nCompositeDBField is now an interface to nested fields on an underlying dataobject, allowing field manipulation to be performed at the field and dataobject level without having to synchronise them manually.\r\n\r\nCleanup and rationalisation of changes:\r\n\r\n* ViewableData::castingHelper is overridden in DataObject rather than it trying to do magic reflection on its subclasses. Better to override than try to build in too much logic into a base class.\r\n* Money::getName Renamed to getCurrencyName, since it conflicted with DBField::getName which had a different purpose.\r\n* markChanged parameter added to DBField::setValue in order to make the API consistent between CompositeDBField and DBField.\r\n* DBField::setValue has been updated in a few instances in order to better interact with any parent dataobject. PrimaryKey will use the $record parameter for generating a default formfield, and DBField objects will record which tables they should use for augmenting dataqueries (so better SQL is generated).\r\n* All existing compositeDBFields were re-written to support this being an abstract base class, instead of an interface.\r\n* CompositeDBField now works closer as an interface on top of an underlying DataObject, with get/setField and dbObject to support casting and modification of its sub-field data. As with DBField, setValue is used to bind it to a parent object with which it uses as a data source. Check CompositeDBFieldTest::testFieldBinding for an example of how this works in practice.\r\n* As a result of some of this API change, special cases in DataObject::dbObject have been consolidated together. $fixed_fields['ID'] has been changed from type 'Int' to 'PrimaryKey' (because that's what it is).\r\n* DataObject::get/setField changed to resolve regressions in assigning values as DBField instances.\r\n* DataObject::getChangedFields had to be changed to fix an infinite loop in CompositeDBField::isChanged.\r\n* DataObject::composite_fields now includes polymorphic foreign key fields.\r\n* PolymorphicForeignKey has been changed from Int/Enum to Int/Varchar due to it performing excessive schema queries. Possibly worth looking into again in the future (if we can force it to only query during dev/build).\r\n* ClassName field was refactored into a separate DBField subclass in order to better encapsulate the shared logic in DataObject and PolymorphicForeignKey. A better mechanism is used to ensure that obsolete-class queries are only performed during dev/build.","created_at":"2015-09-08T02:08:00Z","updated_at":"2015-09-21T21:57:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a4fd2a5f8ca743c5a2b63196ab4707816da2f5c","assignee":null,"milestone":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/milestones/7","html_url":"https://github.com/silverstripe/silverstripe-framework/milestones/4.0","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/milestones/7/labels","id":598745,"number":7,"title":"4.0","description":"Things we would like to see in 4.0 but are too large/break too much for a 3.x release.","creator":{"login":"simonwelsh","id":125915,"avatar_url":"https://avatars.githubusercontent.com/u/125915?v=3","gravatar_id":"","url":"https://api.github.com/users/simonwelsh","html_url":"https://github.com/simonwelsh","followers_url":"https://api.github.com/users/simonwelsh/followers","following_url":"https://api.github.com/users/simonwelsh/following{/other_user}","gists_url":"https://api.github.com/users/simonwelsh/gists{/gist_id}","starred_url":"https://api.github.com/users/simonwelsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonwelsh/subscriptions","organizations_url":"https://api.github.com/users/simonwelsh/orgs","repos_url":"https://api.github.com/users/simonwelsh/repos","events_url":"https://api.github.com/users/simonwelsh/events{/privacy}","received_events_url":"https://api.github.com/users/simonwelsh/received_events","type":"User","site_admin":false},"open_issues":29,"closed_issues":5,"state":"open","created_at":"2014-03-15T20:48:10Z","updated_at":"2015-09-15T05:41:57Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590/commits","review_comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590/comments","review_comment_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/4590/comments","statuses_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/statuses/e25ffab6bca2f7091a07e2efb31c2d5987ace17a","head":{"label":"tractorcow:pulls/4.0/make-compositedbfield-useful","ref":"pulls/4.0/make-compositedbfield-useful","sha":"e25ffab6bca2f7091a07e2efb31c2d5987ace17a","user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"repo":{"id":5337017,"name":"silverstripe-framework","full_name":"tractorcow/silverstripe-framework","owner":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tractorcow/silverstripe-framework","description":"SilverStripe's Sapphire Framework","fork":true,"url":"https://api.github.com/repos/tractorcow/silverstripe-framework","forks_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/forks","keys_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/teams","hooks_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/hooks","issue_events_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/issues/events{/number}","events_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/events","assignees_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/assignees{/user}","branches_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/branches{/branch}","tags_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/tags","blobs_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/languages","stargazers_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/stargazers","contributors_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/contributors","subscribers_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/subscribers","subscription_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/subscription","commits_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/contents/{+path}","compare_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/merges","archive_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/downloads","issues_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/issues{/number}","pulls_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/labels{/name}","releases_url":"https://api.github.com/repos/tractorcow/silverstripe-framework/releases{/id}","created_at":"2012-08-08T04:07:21Z","updated_at":"2015-06-01T22:15:10Z","pushed_at":"2015-09-21T05:38:20Z","git_url":"git://github.com/tractorcow/silverstripe-framework.git","ssh_url":"git@github.com:tractorcow/silverstripe-framework.git","clone_url":"https://github.com/tractorcow/silverstripe-framework.git","svn_url":"https://github.com/tractorcow/silverstripe-framework","homepage":"http://silverstripe.org/","size":57261,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":0,"default_branch":"3.2"}},"base":{"label":"silverstripe:master","ref":"master","sha":"43430e27cf54aabbd3c3231bc34c163c5722b8e9","user":{"login":"silverstripe","id":379348,"avatar_url":"https://avatars.githubusercontent.com/u/379348?v=3","gravatar_id":"","url":"https://api.github.com/users/silverstripe","html_url":"https://github.com/silverstripe","followers_url":"https://api.github.com/users/silverstripe/followers","following_url":"https://api.github.com/users/silverstripe/following{/other_user}","gists_url":"https://api.github.com/users/silverstripe/gists{/gist_id}","starred_url":"https://api.github.com/users/silverstripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silverstripe/subscriptions","organizations_url":"https://api.github.com/users/silverstripe/orgs","repos_url":"https://api.github.com/users/silverstripe/repos","events_url":"https://api.github.com/users/silverstripe/events{/privacy}","received_events_url":"https://api.github.com/users/silverstripe/received_events","type":"Organization","site_admin":false},"repo":{"id":1318892,"name":"silverstripe-framework","full_name":"silverstripe/silverstripe-framework","owner":{"login":"silverstripe","id":379348,"avatar_url":"https://avatars.githubusercontent.com/u/379348?v=3","gravatar_id":"","url":"https://api.github.com/users/silverstripe","html_url":"https://github.com/silverstripe","followers_url":"https://api.github.com/users/silverstripe/followers","following_url":"https://api.github.com/users/silverstripe/following{/other_user}","gists_url":"https://api.github.com/users/silverstripe/gists{/gist_id}","starred_url":"https://api.github.com/users/silverstripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silverstripe/subscriptions","organizations_url":"https://api.github.com/users/silverstripe/orgs","repos_url":"https://api.github.com/users/silverstripe/repos","events_url":"https://api.github.com/users/silverstripe/events{/privacy}","received_events_url":"https://api.github.com/users/silverstripe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/silverstripe/silverstripe-framework","description":"SilverStripe Framework, the MVC framework that powers SilverStripe CMS","fork":false,"url":"https://api.github.com/repos/silverstripe/silverstripe-framework","forks_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/forks","keys_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/teams","hooks_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/hooks","issue_events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/events{/number}","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/events","assignees_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/assignees{/user}","branches_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/branches{/branch}","tags_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/tags","blobs_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/languages","stargazers_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/stargazers","contributors_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/contributors","subscribers_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/subscribers","subscription_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/subscription","commits_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/contents/{+path}","compare_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/merges","archive_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/downloads","issues_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues{/number}","pulls_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels{/name}","releases_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/releases{/id}","created_at":"2011-02-02T02:04:13Z","updated_at":"2015-09-16T20:12:10Z","pushed_at":"2015-09-21T13:54:12Z","git_url":"git://github.com/silverstripe/silverstripe-framework.git","ssh_url":"git@github.com:silverstripe/silverstripe-framework.git","clone_url":"https://github.com/silverstripe/silverstripe-framework.git","svn_url":"https://github.com/silverstripe/silverstripe-framework","homepage":"http://silverstripe.org/","size":105332,"stargazers_count":465,"watchers_count":465,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":523,"mirror_url":null,"open_issues_count":618,"forks":523,"open_issues":618,"watchers":465,"default_branch":"3"}},"_links":{"self":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590"},"html":{"href":"https://github.com/silverstripe/silverstripe-framework/pull/4590"},"issue":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/4590"},"comments":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/4590/comments"},"review_comments":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590/comments"},"review_comment":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/pulls/4590/commits"},"statuses":{"href":"https://api.github.com/repos/silverstripe/silverstripe-framework/statuses/e25ffab6bca2f7091a07e2efb31c2d5987ace17a"}}}}