[Dbix-class] Re: Adding a column to a result set
James R. Leu
jleu at mindspring.com
Tue Jun 26 19:35:31 GMT 2007
On Tue, Jun 26, 2007 at 10:09:13AM -0700, John Napiorkowski wrote:
>
> --- "James R. Leu" <jleu at mindspring.com> wrote:
>
> > I know its poor form to respond to your own post,
> > but since I've not seen
> > a response, I just want to make sure I'm not missing
> > something. Can the
> > answer to my question be found someplace obvious?
> > Am I trying to do
> > something that is considered absurd or pointless?
> > Or is what I'm trying
> > to do just not possible.
> >
> > Thanks
> >
> > On Mon, Jun 25, 2007 at 07:19:52PM +0000, James R.
> > Leu wrote:
> > > I'm using DBIx::Class with Catalyst. I have
> > implemented a Model that
> > > acts as an aggregator for multiple Models based on
> > the same
> > > DBIx::Class::Schema. Each query to the Model is
> > executed on all
> > > of the children Models, and a new resultset that
> > represents the data
> > > from all of them is returned. I would like to add
> > a new column to that
> > > resultset indicating which child Model, that row
> > cam from.
> > >
> > > Is there an easy way to add new column to each row
> > of a resultset for
> > > which I assign the data?
> > >
> > > I was thinking of using Class::Accessor to just
> > add another mutator to each
> > > DBIx::Class, and then set the data as it passes
> > through my Model,
> > > but this seems 'hackish' ... not like my approach
> > so far isn't but this
> > > seems even more so, plus it's crossing the lines
> > of adding 'Model' logic
> > > to the DBIx::Class.
> > >
> > > --
> > > James R. Leu
> > > jleu at mindspring.com
>
> Hey,
>
> I could use a little help understanding your data
> model. Is the 'master' resultset a supertype for the
> children, like in a 'has-one' type relationship? Or
> is the relationship between the parent and children
> not represented in your Schema model?
>
> --John
I've implement a Catalyst::Model class that traps all of the calls that would
normally be handled by Catalyst::Model::DBIC::Schema or DBIx::Class and
then loop through all of the child models. The data is then shipped
back in a ResultSet that I build. I build the list of child Models
in ACCEPT_CONTEXT based on the credentials of the user.
So, ideally I'm looking to modify each row adding a virtual field that is the
name of the child model that retrieved the data.
> ____________________________________________________________________________________
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
> http://answers.yahoo.com/dir/?link=list&sid=396546091
--
James R. Leu
jleu at mindspring.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070626/fbac6f68/attachment.pgp
More information about the Dbix-class
mailing list