[Dbix-class] unexpected behavior using select with inflate_result
I wrote some code similar to: my $row = $self->search_related('xyzes', {}, { select => "colABC", as => "colABC" }->first(); xyzes is of type XYZ Because of the "select", I was not expecting inflate_result on XYZ to be called, however it is. ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Can't find source for XXX question
If the data is coming from the DB it does not use the "new" sub it uses a sub inflate_result. Start by looking at these (search for inflate_result) https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod https://metacpan.org/pod/DBIx::Class::Row#inflate_result On Fri, Nov 30, 2018 at 12:58 AM ejm wrote: > Hi All, > > Another newbie question about the "Can't find source for XXX" error > message. > > I've been able to establish a connection to my MySQL DB by specifying a > storage type for my Schema, > but I keep getting the "Can't find source for XXX" error message when I > try searching the table XXX. > > In my Schema object I have : > > __PACKAGE__->load_namespaces(); > > and the usual "use base qw(DBIx::Class::Schema); > > so that methods are correctly inherited from DBIx::Class::Schema. > > Then I have a new constructor in my Schema object which blesses my object > in the namespace I need it in: > > sub new { > my ($proto, $db) = @_; > my $class = ref($proto) || $proto; > my $self = bless {}, $class; > > $self->storage_type('::DBI::mysql'); > return $self->connect($dsn, $dbuser, $dbpw, { AutoCommit => 1}); > } > > where $db is the MySQL DB I need to access and $dbuser, $dbpw are local > variables containing the usual User and PW. > > and $dsn = "dbi:mysql:database=$db"; > > I've checked the object returned by the constructor and it has the > expected entries: > > class_mappings => { 'X::Y::Z::Result::Table1' => 'Table1', > 'X::Y::Z::Result::Table2' => 'Table2', > ... >}, > > source_registrations => { > 'Table1' => bless( { 'result_class' => > 'X::Y::Z::Result::Table1', >'resultset_class' => > 'X::Y::Z::ResultSet::Table1', >'name' => 'Table1', >'source_name' => 'Table1', > ... > }, > 'DBIx::Class::ResultSource::Table'}, > > ... > }, > > storage => { '_connect_info' => [ 'dbi:mysql:database=VSO', > 'dbuser', > 'dbpw', > { > 'AutoCommit' => 1 > }, > '_conn_pid' => 10779, > ... > > } > > > I see an entry in source_registrations for each of the tables in the DB > VSO, all with their correct columns. > However, I noted that the objects are all blessed into the generic > DBIx::Class::ResultSource::Table class and not > the X::Y::Z::ResultSource::Table1 class as I would have expected. > > Is that why I am getting the "Can't find source ..." error message ? > > I have a package for each table in X::Y::Z::Result namespace and > additionally a package for the table I am testing > in both X::Y::Z::ResultSource::Table1 and X::Y::Z::ResultSet::Table1 > > I noted that the resultset_class key above was indeed set to my > namespace-specific package for my test table. > > Any tips or ideas would be greatly appreciated. > > > Thanks, > > --Ed > > > > > > > > ___ > 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/dbix-class@lists.scsys.co.uk > ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] relationship with additional constraints?
The following (below) I sent to "Frew" upon which he updated the post to indicate that the hack does not work. (Some of his hack does work and some not.) In his example is: my @rows = do { local $My::Schema::Result::Foo::SHARE_TYPE = [1, 2]; $rs->search(undef, { join => 'output_devices' })->all }; This usage still works having the local and "all" in the same scope. someone shared with me your https://blog.afoolishmanifesto.com/posts/dbix-class-parameterized- relationships/#extended-relationship-refresher I ran into a problem with the wrapping into a resultset method At the time the "all" is called the "local" has gone out of scope so the die gets triggered die "no share_type specified!" unless $SHARE_TYPE; For myself I had to have this as the last in the chain and in the resultset method call the all itself. On Thu, May 17, 2018 at 12:35 PM, Andrew Beverleywrote: > On Thu, 17 May 2018 11:12:45 +0200 do...@united-domains.de wrote: > > Is it possible to create a relationship which has, along with the > > join condition, an additional constraint where the value could > > somehow be passed when the search() method is called? > > This should answer your question: > > https://blog.afoolishmanifesto.com/posts/dbix-class-parameterized- > relationships/ > > Interestingly the post has been updated since I last looked at it > saying that approach no longer works. I'm not sure why, as it still > seems to work for me. Frew - can you elaborate? > > > - Get a list of all movies, as well as a review by Sue if it exists > > - If a movie does not have a review by Sue then it should still be > > returned with reviews.text = NULL. > > - If a movie does not have a review by Sue but it has a review by > > someone else then it should also be returned with reviews.text = NULL > > The other method you might want to consider is using a correlated > sub-query. It's a little cleaner from a DBIx::Class viewpoint, but I > think you'd need to pull out each review column separately, so would > depend what you want to retrieve. Another excellent blog from Frew: > > https://blog.afoolishmanifesto.com/posts/introducing-dbix-class-helper- > resultset-correlaterelationship/ > > It allows you to do something like this (untested): > > '+columns' => { > sue_review => $self->schema->resultset('Review') >->correlate('movies') >->search({ person => 'sue' }) >->get_column('review_text') >->as_query, > }, > > Andy > > > ___ > 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/ > dbix-class@lists.scsys.co.uk > ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] random Stub found while resolving method "???" overloading """" in package "XXX"
We've in the past few weeks relocated our server and are randomly (but too often) getting the follow error. The dbix verison is now 0.082820 and previously was 0.08250 without this error occurring. "Stub found while resolving method "???" overloading in package "XXX" at /home/perlbrew/.perlbrew/libs/perl-5.16.3@latest-20160209/lib/perl5/DBIx/Class/Row.pm line 1250." the package XXX has which might be related use Class::Trait qw( TPrintable ); sub inflate_result { my $self = shift; my $ret = $self->next::method(@_); my $typeCd = $ret->typeCd; given ($typeCd) { when( $specialTypeCd ) { $self->ensure_class_loaded( $specialSubClass ); bless ($ret, $specialSubClass); } default { bless ($ret, $self); } } return $ret; } The code bringing in package XXX has a helper method doing: my $theY = $c->model('DB::Y')->find( $yID, { prefetch => [ { 'xxxs' => 'typecd' } , 'zid' ] }); return $theY; thoughts in what the problem is; how to get it consistent to submit a bug report. We already know about the potential workaround in Abstract.pm of SQLA_ISVALUE_IGNORE_AUTOGENERATED_STRINGIFICATION=1 ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Merging ResultSets
Matt will your way though not have multiple trips to the db? On Wed, Apr 19, 2017 at 3:17 AM, Matt S Troutwrote: > On Tue, Apr 18, 2017 at 05:20:55PM +0300, Vladimir Melnik wrote: > > On Tue, Apr 18, 2017 at 02:43:55PM +0100, Dagfinn Ilmari Mannsåker wrote: > > > What you are looking for is the 'union_all' method from > > > https://metacpan.org/pod/DBIx::Class::Helper::ResultSet::SetOperations > > > > Thank you very much, it's exactly what I've been looking for! > > Note that if you don't need an actual UNION query you can also do - > > my $merged = $schema->resultset('Foo'); > $merged->set_cache([ map $_->all, $rs1, $rs2, $rs3 ]); > > and then iterating $merged will just use the cache. > > This may or may not be better, depending on your goal. > > -- > Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a > clue > > http://shadowcat.co.uk/blog/matt-s-trout/ http://twitter.com/shadowcat_ > mst/ > > Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN > commercial support, training and consultancy packages could help your team. > > ___ > 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/ > dbix-class@lists.scsys.co.uk > ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] might_have and prefetch it's relationships on first access?
Example I have a table that might_have an expansion board; an expansion board has_many locks Is it possible to when the might_have is first accessed to prefetch the locks? (Yes I know that when I get the table I can prefetch the board and it's locks; just wondering if I have to do it this way.) ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] using store_column as cache?
I know that when loading in from the DB I can use a "+select..." to add in additional column(s). I can then check to see if the column(s) were loaded by "+select" using "has_column_loaded" If a transient "column" is fetched the first time another way and not the "+select"; I'd like to do "store_column" to cache the value so that the next time has_column_loaded would be true and it would act as a cache. Since this is a transient column that is not in the database I assume I should not use "set_column" since the column and the object would be considered dirty and a subsequent update could be impacted. Does this seem correct? thanks in advance. ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Error on sub class
Petter if I remove the check (line 1909) everything else seems to behave sensibly. Before you just go off and remove it I noticed that there is a little more going on here. We are using Catalyst and it is called for simplicity YYY. I just noticed that the error message is that it is expected a YYY::Model::DB::Document.pm, while the parent package name is YYY::Schema::Document.pm On Mon, Jan 19, 2015 at 5:17 AM, Peter Rabbitson rabbit+d...@rabbit.us wrote: On 01/16/2015 11:41 AM, Mitchell Elutovich wrote: $perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi $ perl -MDBIx::Class -le 'print $DBIx::Class::VERSION' 0.082810 Anyone know why I might be now running into this? I'm not sure how long this problem has existed and I thought I was originally using the sub class ok. This is a new check that was introduced during the 0.0828xx series. It was introduced due to a lot of abuse-cases of the relationship system. Nevertheless in this case it seems like a false positive - i.e. your usage seems valid. Can you please disable the exception-check in question in DBIx::Class::ResultSource::_resolve_relationship_condition, and tell me if everything else seems to behave in a sensible manner? If this is the case - I would have to remove this check going forward. ___ 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/ dbix-class@lists.scsys.co.uk ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] Error on sub class
$perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi $ perl -MDBIx::Class -le 'print $DBIx::Class::VERSION' 0.082810 Anyone know why I might be now running into this? I'm not sure how long this problem has existed and I thought I was originally using the sub class ok. [2015/01/16 10:29:03] ERROR VLjn2099aP8AAFDcB7sA View/TT.pm:245 Catalyst.View.TT - Couldn't render template xxx/yyy/index.tt2: undef error - DBIx::Class::ResultSource::_resolve_relationship_condition(): Arg\ ument 'self_result_object' must be an object of class 'CatTxA::Model::DB::Document' at /mnt/ext1/melutovich/cvc/repo/CatTxA/script/../lib/CatTxA/Schema/Document.pm line 716 Line 716 is like: my $result = $doc-documenttypecd-doSomething(); At the beginning of Document.pm I've got. my ($xxxDocumentTypeCd) = (qw(XXX)); my $xxxSubClass = __PACKAGE__ . '::' . $xxxDocumentTypeCd; sub inflate_result { my $self = shift; my $ret = $self-next::method(@_); my $documentTypeCd = $ret-documentTypeCd; given ($documentTypeCd) { when( $xxxDocumentTypeCd ) { $self-ensure_class_loaded( $xxxSubClass ); bless ($ret, $xxxSubClass); } default { bless ($ret, $self); } } return $ret; } thanks in advance. ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] Error on sub class
I've checked and my perl DBIX version is not as a quoted but rather is 0.08196 On Fri, Jan 16, 2015 at 5:41 AM, Mitchell Elutovich melutov...@gmail.com wrote: $perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi $ perl -MDBIx::Class -le 'print $DBIx::Class::VERSION' 0.082810 Anyone know why I might be now running into this? I'm not sure how long this problem has existed and I thought I was originally using the sub class ok. [2015/01/16 10:29:03] ERROR VLjn2099aP8AAFDcB7sA View/TT.pm:245 Catalyst.View.TT - Couldn't render template xxx/yyy/index.tt2: undef error - DBIx::Class::ResultSource::_resolve_relationship_condition(): Arg\ ument 'self_result_object' must be an object of class 'CatTxA::Model::DB::Document' at /mnt/ext1/melutovich/cvc/repo/CatTxA/script/../lib/CatTxA/Schema/Document.pm line 716 Line 716 is like: my $result = $doc-documenttypecd-doSomething(); At the beginning of Document.pm I've got. my ($xxxDocumentTypeCd) = (qw(XXX)); my $xxxSubClass = __PACKAGE__ . '::' . $xxxDocumentTypeCd; sub inflate_result { my $self = shift; my $ret = $self-next::method(@_); my $documentTypeCd = $ret-documentTypeCd; given ($documentTypeCd) { when( $xxxDocumentTypeCd ) { $self-ensure_class_loaded( $xxxSubClass ); bless ($ret, $xxxSubClass); } default { bless ($ret, $self); } } return $ret; } thanks in advance. ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] custom result source calling a stored procedure
For a customer result source, I know we can do something such as: $new_source-name( \SQL ); ( SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.user_id WHERE f.friend_user_id = ? UNION SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.friend_user_id WHERE f.user_id = ? ) SQL is there any restrictions on the SQL; is it possible to have the SQL just be a call to a stored procedure? ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] custom result source calling a stored procedure
Will misunderstood my question instead of the SELECT ... can I do something like? $new_source-name( \SQL ); call mystoredproc(?); SQL On Tue, Jun 10, 2014 at 7:59 AM, Will Crawford billcrawford1...@gmail.com wrote: $users-search ( [ { 'user_friends.user_id' = $id }, { 'user_friends.friend_user_id' = $id } ], { join = 'user_friends' } )-all On 10 June 2014 12:18, Mitchell Elutovich melutov...@gmail.com wrote: For a customer result source, I know we can do something such as: $new_source-name( \SQL ); ( SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.user_id WHERE f.friend_user_id = ? UNION SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.friend_user_id WHERE f.user_id = ? ) SQL is there any restrictions on the SQL; is it possible to have the SQL just be a call to a stored procedure? ___ 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/dbix-class@lists.scsys.co.uk ___ 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/dbix-class@lists.scsys.co.uk ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] custom result source calling a stored procedure
In the package which has the source I've defined the columns and defined an inflate_result method which blesses $self to a subclass of the package based on a type column Currently I've just been using a complex SQL of a union of multiple SELECTs. However, I would like to create a temporary table or two and so I wanted to put everything into a stored proc. On Tue, Jun 10, 2014 at 2:07 PM, Peter Rabbitson rabbit+d...@rabbit.us wrote: On Tue, Jun 10, 2014 at 07:18:29AM -0400, Mitchell Elutovich wrote: For a customer result source, I know we can do something such as: $new_source-name( \SQL ); ( SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.user_id WHERE f.friend_user_id = ? UNION SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.friend_user_id WHERE f.user_id = ? ) SQL is there any restrictions on the SQL; is it possible to have the SQL just be a call to a stored procedure? Is there a reason you want to put the sproc behind a source? Why not simply do my @results = $schema-storage-dbh_do(sub { $_[1]-selectall_arrayref(... sproc here ... ) } ); Cheers ___ 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/dbix-class@lists.scsys.co.uk ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] nullable column and might_have
I have something like the following on a custom result source __PACKAGE__-add_columns( xxxid, { data_type = INT, default_value = undef, is_nullable = 1, size = 11 }, ); __PACKAGE__-might_have( xxxd, ForeignClass, { foreign.id = self.xxxid }, ); I'm getting the warning: DBIx::Class::Relationship::HasOne::_validate_has_one_condition(): might_have/has_one must not be on columns with is_nullable set to true (MyClass/xxxid). This might indicate an incorrect use of those relationship helpers instead of belongs_to. at ... I don't understand why this for might_have might be incorrect, doesn't might_have imply it might be null? ___ 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/dbix-class@lists.scsys.co.uk
[Dbix-class] custom resultsource and subclasses
I have the need for a custom resultsource based on the SQL select of a union of multiple tables; I would like to have a different subclass associated with each table and I would have a column which indicated which subclass to choice. In a normal result set I know that there is an inflate_result method called which I can hook into to have the results blessed correctly; does the inflate_result or equivalent get used for a custom resultsource ? ___ 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/dbix-class@lists.scsys.co.uk
Re: [Dbix-class] custom resultsource and subclasses
*Louis Erickson:* **You mean like DBIx::Class::DynamicSubclass? The only odd part is the union of sql select, which sounds like a view to me. I'll have to think about the possibility of just using a view instead of a resultsource. Yes I've used DynamicSubclass in which it is described (in the Cookbook.pod#Dynamic_Sub-classing_DBIx::Class_proxy_classes) as: |DBIx::Class classes are proxy classes, therefore some different techniques need to be employed for more than basic subclassing. In this example we have a single user table that carries a boolean bit for |admin. We would like to give the admin users objects (DBIx::Class::Row) the same methods as a regular user but also special admin only methods. It doesn't make sense to create two separate proxy-class |files for this. We would be copying all the user methods into the Admin class. There is a cleaner way to accomplish this. | |Overriding the inflate_result method within the User proxy-class gives us the effect we want. This method is called by DBIx::Class::ResultSet when inflating a result from storage. So we grab the object being |returned, inspect the values we are looking for, bless it if it's an admin object, and then return it. Which based on this, I believe my question boils down to if I use a custom resultsource to select rows from the database, is DBIx::Class::ResultSet still used and does it still call the inflate_result method. Based on the following from the Cookbook it looks like the answer to the questions is that it is using ResultSet and I presume it should be calling inflate_result, but it will need testing(unless someone already knows this). Arbitrary SQL through a custom ResultSourcehttp://perl.mines-albi.fr/perl5.8.5/site_perl/5.8.5/DBIx/Class/Manual/Cookbook.html#arbitrary_sql_through_a_custom_resultsource Sometimes you have to run arbitrary SQL because your query is too complex (e.g. it contains Unions, Sub-Selects, Stored Procedures, etc.) or has to be optimized for your database in a special way, but you still want to get the results as a the DBIx::Class::ResultSet manpagehttp://perl.mines-albi.fr/perl5.8.5/DBIx/Class/ResultSet.html. The recommended way to accomplish this is by defining a separate ResultSource for your query. You can then inject complete SQL statements using a scalar reference (this is a feature of the SQL::Abstract manpagehttp://perl.mines-albi.fr/perl5.8.5/SQL/Abstract.html ). Say you want to run a complex custom query on your user data, here's what you have to add to your User class: package My::Schema::User; use base qw/DBIx::Class/; # -load_components, -table, -add_columns, etc. # Make a new ResultSource based on the User class my $source = __PACKAGE__-result_source_instance(); my $new_source = $source-new( $source ); $new_source-source_name( 'UserFriendsComplex' ); # Hand in your query as a scalar reference # It will be added as a sub-select after FROM, # so pay attention to the surrounding brackets! $new_source-name( \SQL ); ( SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.user_id WHERE f.friend_user_id = ? UNION SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.friend_user_id WHERE f.user_id = ? ) SQL # Finally, register your new ResultSource with your Schema My::Schema-register_source( 'UserFriendsComplex' = $new_source ); Next, you can execute your complex query using bind parameters like this: my $friends = [ $schema-resultset( 'UserFriendsComplex' )-search( {}, { bind = [ 12345, 12345 ] } ) ]; ... and you'll get back a perfect LDBIx::Class::ResultSet. ___ 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/dbix-class@lists.scsys.co.uk