Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Creating a model of a bad database

by ph713 (Pilgrim)
on Dec 12, 2006 at 19:18 UTC ( [id://589368]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Creating a model of a bad database
in thread Creating a model of a bad database

I'm guessing by that you mean insert/update to a database view, or something very like a view. DBIx::Class doesn't yet do that, and I don't know that it ever will. In PostgreSQL you can only do it by defining custom rules for the view AFAIK. I haven't had any personal experience with a database that does it with no extra work, if there are any. Topics like this have been discussed on irc.perl.org #dbix-class before, but implementing them in the generic case is tricky at best.

Along these kinds of lines, the best we could offer at the moment is that you can make a ResultSource class for view just like you could for a table (if your database doesn't support real views, that can be hacked as well, by basically specifying the SQL that generates the view as the table name, IIRC), and then you could override the update and insert methods for this source and include your own custom code that breaks out the data and does the insert/update to the underlying tables (either using DBIC abstractions of those tables, or raw sql via a dbh accessor).

  • Comment on Re^3: Creating a model of a bad database

Replies are listed 'Best First'.
Re^4: Creating a model of a bad database
by perrin (Chancellor) on Dec 12, 2006 at 19:25 UTC
    The custom ResultSource doesn't sound too bad. The reason I ask is that it sounds like that's what Ovid will need here, with a database schema that he wants to abstract away. Otherwise, he'd have to make his API deal with the actual tables as they currently are.

      Well, as much as possible, I'll simply be denying people accessors and mutators. They'll get the behaviors they need and that's it. Of course, it's not quite that simple, but by focusing on behavior instead of data (which is what OO should be doing anyway), I think I can contain the worst of the problem.

      Cheers,
      Ovid

      New address of my CGI Course.

Re^4: Creating a model of a bad database
by sgt (Deacon) on Dec 13, 2006 at 14:15 UTC

    I haven't used DBIx::Class or another ORM module (this is long due actually...) but from a model perpective views are usually to drive queries. Inserts or Updates on views will be in general very database-dependent or even not supported (or via custom-made procedures that usually defeat the use of an ORM)

    Am I missing something?

    hth --stephan

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-19 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found