{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1184","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1184/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1184/comments","events_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1184/events","html_url":"https://github.com/doctrine/mongodb-odm/pull/1184","id":97972017,"number":1184,"title":"Add support for custom mapping type for object IDs","user":{"login":"marcospassos","id":943036,"avatar_url":"https://avatars.githubusercontent.com/u/943036?v=3","gravatar_id":"","url":"https://api.github.com/users/marcospassos","html_url":"https://github.com/marcospassos","followers_url":"https://api.github.com/users/marcospassos/followers","following_url":"https://api.github.com/users/marcospassos/following{/other_user}","gists_url":"https://api.github.com/users/marcospassos/gists{/gist_id}","starred_url":"https://api.github.com/users/marcospassos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcospassos/subscriptions","organizations_url":"https://api.github.com/users/marcospassos/orgs","repos_url":"https://api.github.com/users/marcospassos/repos","events_url":"https://api.github.com/users/marcospassos/events{/privacy}","received_events_url":"https://api.github.com/users/marcospassos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/mongodb-odm/labels/feature","name":"feature","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"alcaeus","id":383198,"avatar_url":"https://avatars.githubusercontent.com/u/383198?v=3","gravatar_id":"","url":"https://api.github.com/users/alcaeus","html_url":"https://github.com/alcaeus","followers_url":"https://api.github.com/users/alcaeus/followers","following_url":"https://api.github.com/users/alcaeus/following{/other_user}","gists_url":"https://api.github.com/users/alcaeus/gists{/gist_id}","starred_url":"https://api.github.com/users/alcaeus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alcaeus/subscriptions","organizations_url":"https://api.github.com/users/alcaeus/orgs","repos_url":"https://api.github.com/users/alcaeus/repos","events_url":"https://api.github.com/users/alcaeus/events{/privacy}","received_events_url":"https://api.github.com/users/alcaeus/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/milestones/3","html_url":"https://github.com/doctrine/mongodb-odm/milestones/1.x","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/milestones/3/labels","id":617128,"number":3,"title":"1.x","description":"Milestone for post-1.0.0 features.","creator":{"login":"jmikola","id":244663,"avatar_url":"https://avatars.githubusercontent.com/u/244663?v=3","gravatar_id":"","url":"https://api.github.com/users/jmikola","html_url":"https://github.com/jmikola","followers_url":"https://api.github.com/users/jmikola/followers","following_url":"https://api.github.com/users/jmikola/following{/other_user}","gists_url":"https://api.github.com/users/jmikola/gists{/gist_id}","starred_url":"https://api.github.com/users/jmikola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmikola/subscriptions","organizations_url":"https://api.github.com/users/jmikola/orgs","repos_url":"https://api.github.com/users/jmikola/repos","events_url":"https://api.github.com/users/jmikola/events{/privacy}","received_events_url":"https://api.github.com/users/jmikola/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":1,"state":"open","created_at":"2014-04-01T18:31:45Z","updated_at":"2015-07-30T17:26:14Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-07-29T16:10:45Z","updated_at":"2015-07-30T19:40:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1184","html_url":"https://github.com/doctrine/mongodb-odm/pull/1184","diff_url":"https://github.com/doctrine/mongodb-odm/pull/1184.diff","patch_url":"https://github.com/doctrine/mongodb-odm/pull/1184.patch"},"body":"Implements #1178 and #1179 (merges  #1181 and #1182 into a single PR).\r\n\r\nAdds a note in documentation for examplaing the implemention details required for using custom types as object IDs."},"comment":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/comments/126451234","html_url":"https://github.com/doctrine/mongodb-odm/pull/1184#issuecomment-126451234","issue_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1184","id":126451234,"user":{"login":"alcaeus","id":383198,"avatar_url":"https://avatars.githubusercontent.com/u/383198?v=3","gravatar_id":"","url":"https://api.github.com/users/alcaeus","html_url":"https://github.com/alcaeus","followers_url":"https://api.github.com/users/alcaeus/followers","following_url":"https://api.github.com/users/alcaeus/following{/other_user}","gists_url":"https://api.github.com/users/alcaeus/gists{/gist_id}","starred_url":"https://api.github.com/users/alcaeus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alcaeus/subscriptions","organizations_url":"https://api.github.com/users/alcaeus/orgs","repos_url":"https://api.github.com/users/alcaeus/repos","events_url":"https://api.github.com/users/alcaeus/events{/privacy}","received_events_url":"https://api.github.com/users/alcaeus/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T19:40:45Z","updated_at":"2015-07-30T19:40:45Z","body":"@marcospassos as for #1178, my comment explains why you ran into issues - I think we can fix that with minor changes to ClassMetadata not overriding a given ID type when using the NONE strategy (or you can use the workaround I mentioned above by specifying a generator type). This should not require any other changes since it's just a mapping issue.\r\n\r\nAs for type casting in queries, casting to string is not exactly the correct way. Remember that not every type needs to resolve to a string in ODM.\r\nWhen inserting documents, the type mapping is used to get the correct database representation using the ```convertToDatabaseValue()``` method of the corresponding type class. The same thing should apply when running queries: we have the mapping and thus the type, so why simply cast to string and hope for the best? In the end, simply casting to string would exclude custom types that are stored as arrays or hashes in the database.\r\n\r\nOne more thing: a user can always run ```$queryBuilder->field('stringField')->equals(true)``` - in that case I'd expect no result because we're comparing strings with a boolean value. If the bool value is cast to string based on the type mapping of ```stringField``` this no longer holds true. We should keep that in mind when finding a solution."}}