What goes well with DBIx::Class - the review.
In my case, it went very well with Fideos de Sepia and a nice glass of Fina Enguera.
This is not really a review of Dave's Perl School. His style is competent, informative, sometimes entertaining and pitched right at my level of Perl. Unlike the Moose school I went to in December, this lecture could have gone on for another hour discussing the finer points, but people have lives and we finished at 5pm.
This is more a bit of navel-gazing about what DBIx::Class might mean to me.
As opposed to Moose, where I'd already seen the power and wanted more, I had no real idea about dbic, other than the general feeling that I should get to know something about it. I have a local module where I hide away all the database connections I use to extract data from Oracle, Mysql and Postgres. I use DBI and my skill with SQL is just good enough to get what I want. It's not as onerous as building an object class before Moose came along, so I didn't come back from the School with the immediate urge to convert all my code.
Don't get me wrong - I see the shiny in abstracting away the database interface by letting you describe the data and I will look for an excuse to write new code in dbic, but I'm not seeing the immediate win in migrating. Sure, the dbic will go and read the schema and set up the accessors for me (which you have to admit is really cool), but I already had to read the schema myself to figure out how to get the data out. It's a big win if you need to create a schema from scratch, but is there a way of getting data out of existing tables that I don't intimately know and may not have foreign keys linking tables? Is this where I should be using
Maybe it's a bit like 2001 where I was introduced to Test. I wrote a few because other people said it was a good idea. It wasn't until 6 months later when a test bubbled up a logic error and saved my sanity that I truly understood the power of testing. Perhaps I will experience the same epiphany after I start to use it. That time might come sooner than expected ever since Oracle's accounting script found a feature that silently got turned on at our installation, we've never used, but is horrendously expensive. The Director was livid and wanted to know how fast we could move to Postgres or even (shudder) SQLServer.
- Building SQL statements on the fly - the week before the class, I found myself having to wanting to switch between a select on one table and select joining 2 tables depending on the parameters passed to the function. I think dbic would have saved me some headache
- Doesn't duplicate the schema - I mentioned this earlier. It's just the Right Thing to do.
- Creates a PNG of the schema using SQL::Translator - Shiny!
- DBIC_TRACE shows the SQL that would be generated by your call
- Generates tables on the fly - why didn't I know about this a couple of years ago!
Other things: Transactions, chaining result sets, find() returns a single row.
Things you need to understand: The difference between a Result and a ResultSet. I think if you can grok what a ResultSet is quickly, this module will be your mollusc. Time will only tell whether I do or not.
As planned in the last entry, I did make it to the tapas bar after the school. Nice place just off Old Street, only 10 minutes walk from the Google Campus. Not cheap, but the food was excellent. As everyone else had scurried home, I was on my own. The croquetas I could have happily shared, lovely as they were. Very fine crust and good flavour, but a bit creamy to have all 4 to myself. The fideos de sepia (cuttlefish with pasta noodles) was just a whim - something I've never had before. It was excellently prepared while I watched, the seafood just a little crunchy and ... odd. I still don't know if I like it, but it was worth the £10.
I would go again the next Perl School I come down for (Dave may have his arm twisted into giving sessions on Testing or Web frameworks) and with the menu in hand you could order immediately on arrival and be back for the afternoon session. On the other hand, some of the others came back with Vietnamese takeaway lunch box which looked rather tempting.
So, here's an apt simile. DBIx::Class is like cuttlefish. Intelligent, tasty, slightly mysterious and I'm still making up my mind about it.