Re: how to switch a view easily?

[prev] [thread] [next] [Date index for 2005/04/20]

From: merlyn (Randal L. Schwartz)
Subject: Re: how to switch a view easily?
Date: 13:55 on 20 Apr 2005
>>>>> "Mark" == Mark Addison <mark.addison@xxx.xx.xx> writes:

Mark> What database is this running on? Specifically does it have views?
Mark> If so could you create views for the 2 sets and then use a quick
Mark> sub-class that just changes the table (view) it uses. Then all your
Mark> nifty code is shared by both and the mode can be set by the class you
Mark> use.

Yeah, thought of that, but then I run into a problem with updates,
since views are read-only.  I do things like this:

        for my $booking ($other->bookings) { # don't wanna see cancelled here
          $booking->some_column($new_value); # boom, go bye bye!
        }

The solution I'm going to try in a few moments is to create a view of
just livebooking, then override transform_sql to
s/\bbooking\b/livebooking/g, but only when /^select/i, which should
ignore updates and inserts.  That way I don't have to worry about
some handwritten SQL that looks like

SELECT ... FROM booking b, address a ...

because my previous plan was to replace that "booking" with

  (select * from booking where cancelled_date is null) as booking

and then you got that "b" out there which is not going to work well. :)

        -- 
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

(message missing)

how to switch a view easily?
merlyn (Randal L. Schwartz) 04:21 on 20 Apr 2005

Re: how to switch a view easily?
merlyn (Randal L. Schwartz) 05:11 on 20 Apr 2005

Re: how to switch a view easily?
Tony Bowden 08:26 on 20 Apr 2005

Re: how to switch a view easily?
Dana Hudes 12:07 on 20 Apr 2005

Re: how to switch a view easily?
Mark Addison 13:12 on 20 Apr 2005

Re: how to switch a view easily?
merlyn (Randal L. Schwartz) 13:55 on 20 Apr 2005

Solved (thank you postgresql!) was Re: how to switch a view easily?
merlyn (Randal L. Schwartz) 16:30 on 20 Apr 2005

multi-column PK and has_many
Barry Moore 18:21 on 20 Apr 2005

Re: multi-column PK and has_many
Perrin Harkins 18:41 on 20 Apr 2005

Re: Solved (thank you postgresql!) was Re: how to switch a view easily?
merlyn (Randal L. Schwartz) 17:10 on 20 Apr 2005

Generated at 09:29 on 27 Apr 2005 by mariachi v0.52