{"id":537,"date":"2010-01-29T17:52:33","date_gmt":"2010-01-29T16:52:33","guid":{"rendered":"http:\/\/www.thomaskeller.biz\/blog\/?p=537"},"modified":"2010-09-22T10:38:42","modified_gmt":"2010-09-22T09:38:42","slug":"never-trust-doctrinedata-dump","status":"publish","type":"post","link":"https:\/\/www.thomaskeller.biz\/blog\/2010\/01\/29\/never-trust-doctrinedata-dump\/","title":{"rendered":"Never trust doctrine:data-dump&#8230;"},"content":{"rendered":"<p>&#8230;and especially not if you get the impression that the dump will afterwards be readable by the `doctrine:data-load` command of <a href=\"http:\/\/www.symfony-project.org\">symfony<\/a>.<\/p>\n<p>It was a costly lesson today when I tried to reimport a dump of a couple of <a href=\"http:\/\/www.sympalphp.org\">Sympal<\/a> tables. One of them, the one which models the menu items, has a nested set behaviour, and apparently this one cannot be restored properly by <a href=\"http:\/\/www.doctrine-project.org\">doctrine<\/a>:<\/p>\n<pre>[Doctrine_Record_UnknownPropertyException]                                    \r\n  Unknown record property \/ related component \"children\" \r\n  on \"sfSympalMenuItem\"<\/pre>\n<p>Apparently this particular issue popped up a couple of times in the past for other people as well (<a href=\"http:\/\/www.google.com\/search?q=doctrine+data-load+%22nested+set%22\">Google for it<\/a>) and while the help of `doctrine:data-dump` still (Doctrine 1.2) blatantly states<\/p>\n<p>    The doctrine:data-dump task dumps database data:<\/p>\n<p>     .\/symfony doctrine:data-dump<\/p>\n<p>    The task dumps the database data in data\/fixtures\/%target%.<\/p>\n<p>    The dump file is in the YML format and can be reimported<br \/>\n    by using the doctrine:data-load task.<\/p>\n<p>     .\/symfony doctrine:data-load<\/p>\n<p><small>(with the emphasis of &#8220;can be reimported&#8221;)<\/small><\/p>\n<p>the author of Doctrine, Jonathan Wage, told me today on Sympal&#8217;s IRC (shortened):<\/p>\n<blockquote><p>\n&lt;jonwage> we don&#8217;t want people to think you can dump and then restore<br \/>\n&lt;jonwage> that is not what the data fixtures are for<br \/>\n&lt;jonwage> b\/c dumping and then loading will never work<br \/>\n&lt;jonwage> an ORM modifies data on the way and and the way out<br \/>\n&lt;me> I mean the least thing doctrine could do there is that if it detects the nested set behaviour it should error out clearly on dump<br \/>\n&lt;jonwage> so you can&#8217;t dump the data through an ORM and then try and reload it<br \/>\n&lt;jonwage> i.e. hashed passwords<br \/>\n&lt;me> if dumping is &#8220;never&#8221; going to work &#8211; why do you support dumping into yaml at all?!<br \/>\n&lt;jonwage> if we do that then we would have to throw errors in sooooooo many other cases too<br \/>\n&lt;jonwage> because it is at least a little bit of a convenience<br \/>\n&lt;me> its like a half-baked feature then<br \/>\n&lt;jonwage> we dump the raw data<br \/>\n&lt;jonwage> and you can tweak it<br \/>\n&lt;jonwage> thats my point though, it will ALWAYS be a half baked feature thats why we document it that way<br \/>\n&lt;jonwage> it can NEVER work 100% the way you want it to<br \/>\n&lt;jonwage> so if we fix that one thing, a million other things will be reported that we cannot fix<br \/>\n&lt;jonwage> bc an ORM is not a backup and restore tool<br \/>\n&lt;jonwage> it is impossible\n<\/p><\/blockquote>\n<p>Now I know that as well. My only problem was that I struggled &#8220;what is wrong with my fixtures&#8221; the whole time and never dared to ask &#8220;what is wrong with doctrine&#8221;&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;and especially not if you get the impression that the dump will afterwards be readable by the `doctrine:data-load` command of symfony. It was a costly lesson today when I tried to reimport a dump of a couple of Sympal tables. One of them, the one which models the menu items, has a nested set behaviour, &hellip; <a href=\"https:\/\/www.thomaskeller.biz\/blog\/2010\/01\/29\/never-trust-doctrinedata-dump\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Never trust doctrine:data-dump&#8230;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,26,11],"tags":[],"class_list":["post-537","post","type-post","status-publish","format-standard","hentry","category-coding","category-rants","category-work"],"_links":{"self":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/comments?post=537"}],"version-history":[{"count":8,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/posts\/537\/revisions\/540"}],"wp:attachment":[{"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/media?parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/categories?post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thomaskeller.biz\/blog\/wp-json\/wp\/v2\/tags?post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}