On Sat, Oct 24, 2009 at 8:24 AM, Wallace Reis <[email protected]> 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 cannot >> 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 => 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 [email protected]
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
