[Dbix-class] Dummy DBIC columns?

Alexander Hartmaier alexander.hartmaier at t-systems.at
Wed May 18 09:11:23 GMT 2011


Why not create another result class for the different table?
The overlapping methods can be put in a base class or a role used by both.

Am 2011-05-17 17:14, schrieb Bill Moseley:


On Tue, May 17, 2011 at 7:43 AM, Peter Edwards <peter at dragonstaff.co.uk<mai=
lto:peter at dragonstaff.co.uk>> wrote:
Can you say

my $search_attr =3D {
  '+columns'  =3D> [ { 'email' =3D> \'' } ], # and so on for other missing =
fields
};

then

my $rs =3D $schema->search_rs( $query, $search_attr );

Hi Peter,

Maybe I'm not understanding your suggestion.  The problem I have is an exis=
ting application that uses DBIC, and (perhaps incorrectly) there's quite a =
few direct uses of $user->get_column( 'email' ),  I could probably replace =
those in the app by adding, for example, an "email" method to the result cl=
ass.   There's also other uses of the "email" column such as create() and m=
aybe other resultset methods that verify that every key in the passed in da=
ta is an actual column.

I suspect replacing the get_column() usage is necessary.  But, I'm not sure=
 how best to deal with any other methods that might reference a non-existen=
t column.

Really, what I need to do is prevent the column from ending up in SQL.  So,=
 could I defined the non-existent column in the result class and then overr=
ide the SQL generation somewhere to strip out the columns?  I suspect that'=
s less that trivial.

Other option would be to override insert and create and strip out the non-e=
xistent columns.

Unfortunately, I can't just add the columns to the database.

Any other ideas?

Thanks,



--
Bill Moseley
moseley at hank.org<mailto:moseley at hank.org>

*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
Notice: This e-mail contains information that is confidential and may be pr=
ivileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110518/e04=
af182/attachment.htm


More information about the DBIx-Class mailing list