Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Switch from DBI to DBIx::Class: thoughts?

by bellaire (Hermit)
on Mar 16, 2009 at 21:15 UTC ( [id://751032]=note: print w/replies, xml ) Need Help??

in reply to Switch from DBI to DBIx::Class: thoughts?

The only thing that bothers me about DBIx::Class is, the last time I used it, when the operations you needed surpassed a certain level of complexity, you ended up still passing in SQL syntax in scalar references at certain points, for example when I wanted to select for a column which was within a particular range of values (dates). If you get to that point, you're losing out on the benefit of the abstraction because now you have to have familiarity with the plain SQL as well as the DBIx::Class abstraction. However, I don't know that my experience was typical, or even if I was doing things the right way. YMMV.
  • Comment on Re: Switch from DBI to DBIx::Class: thoughts?

Replies are listed 'Best First'.
Re^2: Switch from DBI to DBIx::Class: thoughts?
by webfiend (Vicar) on Mar 16, 2009 at 22:14 UTC

    I've bumped into that limitation in every ORM I've used, sooner or later. There is eventually no escaping the fact that you're not using the native language of your database. The main solutions I'm aware of are:

    1. Watch SQL gradually take over your application code as you bump into ever more dark corners where the abstraction doesn't hold up;
    2. Tuck your SQL code into methods so that things still looking shiny and ORM-y to users of your code;
    3. Give up on ORMs and use a phrasebook approach.

    1 and 2 are nearly the same, they just involve an executive decision about who has to look at SQL. Option 3 is a pretty significant shift that might not work on a project that already relies heavily on an ORM.

    I guess that means the main option is to suck in your gut and deal with SQL every once in a while. You can't escape it forever.

    Incidentally, I'm not trying to be mean or anything. I'm very sympathetic, just slightly charred from the many times I've seen my lovely abstractions break down in the face of cold cold reality.

      I agree that this is bound to happen. There are no perfect abstractions. But we do want to abstract commonly performed actions and tests. We could migrate away from an ORM and just use models that know how to do some SQL. The point isn't as much to get away from SQL (in my mind) as it is to have Models the represent our objects well. An ORM just makes that nicer for us.

      fREW Schmidt
Re^2: Switch from DBI to DBIx::Class: thoughts?
by zby (Vicar) on Mar 16, 2009 at 22:33 UTC
    I guess it depends on how many complex versus simple queries you have in your application. In the applications I worked on the bulk of queries are really simple (at least below the threshold you mention above) - and justify a bit of more work for the complex ones.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://751032]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-23 07:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found