Archive for August 26th, 2007

Published by Fabian on 26 Aug 2007

lets get … technical – symfony: Propel export and import data

Okay, the intention of this blog was to share also thoughts and tips about software development. So here something I worked with the last two day:

Exporting and importing data with propel as ORM layer.
I read already sometime about problems with exporting and importing data. I can see that the functionality behind that is not that elaborated as it is only a side task. However, I wanted to achieve two things:

  1. test all forms in our web application
  2. save that data as fixtures for future reuse.

Up to now our fixtures were like “hello world” & “dummy 123″ which works for most functionality, but doe snot work for other things, e.g. layout. But there is no good way to generate the data. So I took the hard way, which actually allowed me to user test ALL forms in one go. Normally we had tested them when we created them, but I had to notice that some changes broke some behavior (nothing critical, also a lot of cosmetical things). So I fixed those, and created tons of data. So whats next:

(new sfPropelData())->dumpData(SF_ROOT_DIR . '/data');

Hangs, out of memory, or just stops, with no data generated. The script is very silent, and the code of the 1.0 version not very telling, so I checked the latest version from trac, which had undergone a major overhaul by Fabien.

My initial guess was right, and an added echo in fixOrderingOfForeignKeyData() proved that this was hanging in an endless loop.
Why? because the sfPropelData resolves FK based on tables, not on rows. Which means that between two tables there should be FK’s only in one direction. We had two. An Entity belonged to a Section, and a Section should be also an Entity. This led to that Propel class always changing order of those two tables. Of course a row in Section could reference an Entity that does belong to no, or a different Section and this would not loop, but on table level this is a loop.

I resolved this by removing the FK from Section to Entity and doing the lookup in code myself. After that and a patch I made to the SfPropelData (sent to Fabien and included) it worked great and produced a lot of fixture data. There was still another problem with a null FK, but I also resolved that and sent patch to Fabien (in that case, an Entity not belonging to a section would render following YAML: section_id : Section_ ). Trac issues will follow. I should take all my accounts with me, but I didn’t, so it have to look it up at home.

So the message is: if you have problems with importing and exporting with 1.0.x of symfony and Propel, go ahead and check out the latest trunk version of the propel addon classes.

Published by Fabian on 26 Aug 2007

My first Baseball game

Tonight I watched my first Baseball game (IRL, not on TV). Milwaukee Brewers were at San Francisco Giants. The ballpark in SF is pretty neat. I sat in one of the cheap high seats (called view reserve) but I enjoyed seeing the whole field and the bay and the screen. Pretty good for 26 bucks. Baseball as such is interesting, although it has everything a boring sport needs, it is quite entertaining. From a neutral point of view most of the time one guy trys to throw a ball to his mate, but one with a bat stands inbetween and tries to hit. Sometimes that guy hits and then one of the guys that just stand around jumps and catches it. Then teams swap positions.

Tonights game was not that action packed. I hoped for a Barry Bonds homerun, but was disappointed. He was swapped even end of 6th inning. Once the pitcher avoided him and pitched 4 balls, so he could walk to first base. For those not deep into baseball strategies. This is called a Intentional base on balls, which might be a valid strategy, but I really would have liked to see another Bonds homerun.

Giants won 6-2, which was basically decided after the first inning where they could run 4 players home.

What I really disliked was the 30$ ripp-off for parking on a improvised parking lot. I decided to turn around and drove 3 blocks where I parked for free in a street.

Have a good night or day