[Dbix-class] Left join with an extra condition
Bill Moseley
moseley at hank.org
Sat Oct 24 20:43:33 GMT 2009
On Sat, Oct 24, 2009 at 8:24 AM, Wallace Reis <wallace at reis.org.br> wrote:
> On 24/10/2009, at 11:48, Bill Moseley wrote:
>
> Can the virtual view inherit from the user? That is, can I convince DBIC
>> that the object returned is a real user object so I can update the object
>> and have it written to storage? The cookbook just says that the view ca=
nnot
>> be operated on. Obviously, it would be much more useful to have a real =
user
>> object.
>>
>
> You can do it if you use a DBMS with RULEs support (like PostgreSQL).
>
Are you talking about creating a database view that can be updated?
> Or you can setup a belongs_to rel (where is_foreign_key_constraint =3D> 0=
) to
> the user and override qw/insert delete update/ row methods in your view
> class to do such operations on ->referred_user instead of $self, like you
> would do with RULEs on DBMS.
>
That seems like a complex approach for something seemingly simple. DBIC
allows fetching additional columns when using database functions (e.g
length() ). And my query is returning just a user row and a count. Would
not a simple approach be to run the query and then populate user objects? I
guess I won't have result set to use for count or paging results.
I'm wondering if I'm missing something. Is it really true that with
DBIx::Class if you need a list of objects, but the query to fetch that list
cannot be represented by a search on a resultset then there's no way to use
SQL directly to get the set of objects?
Thanks,
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20091024/61e=
3b169/attachment.htm
More information about the DBIx-Class
mailing list