Re: [Dbix-class] DBIx::Class::Cursor::Cached
Hi Simon, I am forwarding this to the DBIx::Class mailing list, as they may have input. Thanks, Justin On Tue, Apr 22, 2014 at 2:58 PM, Simon Hollier hellosi...@gmail.com wrote: Hi Justin, I needed the ability to purge certain cached queries in different places than where the query gets cached. So, I hacked Cursor::Cached to allow one to specify a cache_key in the attributes so I could purge it elsewhere by this cache_key name. I wanted to see if you had any interest in this simple patch (or maybe point out that I'm missing something obvious) : 28c28 cache_key = $attrs-{cache_key} || $class-_build_cache_key(@_), --- cache_key = $class-_build_cache_key(@_), Thanks! Simon -- Simon Hollier ___ 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] Caching solutions for DBIx::Class
Alex, yes DBIx::Class::Cursor::Cached is maintained and stable. It should do what you're looking for. Thanks, Justin 2011/7/2 Alex Povolotsky tark...@over.ru Hello! I'm looking for a fairly trivial (for now) cache solution to prevent multiple reSELECTs. Internal cache (cache = 1 in search) did not work; DBIx::Class::Cursor::Cached - is it maintainted? Is it stable? Oleg Pronin mentioned some solution posted by me, but I could not find it. Maybe someone can recommend me something? Alex __**_ List: http://lists.scsys.co.uk/cgi-**bin/mailman/listinfo/dbix-**classhttp://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/http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/** dbix-class@lists.scsys.co.ukhttp://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] has_many LEFT JOIN with parameter
Per http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Relationship/Base.pm#condition, under To specify joins which describe more than a simple equality of column values, the custom join condition coderef syntax can be used. For example: __PACKAGE__-has_many( useraccounts, UserAccounts sub { my $args = shift; return { $args-{foreign_alias}.userid = { -ident = $args-{self_alias}.id }, $args-{foreign_alias}.accountid = { '=', $value }, }; } ); not sure where the join_type will go, but that should be the gist. Justin On Fri, May 6, 2011 at 1:50 PM, Ton Voon tonv...@gmail.com wrote: Hi! Is it possible to have a has_many relationship where the LEFT JOIN ON relationship contains a parameter? For instance, something like in User.pm: __PACKAGE__-has_many( useraccounts, UserAccounts, { foreign.userid = self.id, foreign.accountid = $value }, { join_type = left } ); Where $value can be specified as part of the search for the ON condition. Is this possible? Ton ___ 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] Why does this query not work?
according to the cookbook, something like select = [ 'sym', { count = '*', -as = 'stc_count' } ], as = [ qw/ stc stc_count / ], would work. http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Using_database_functions_or_stored_procedures, starting at Note that the as attribute *has absolutely nothing to do* with the SQL syntax SELECT foo AS bar Justin On Wed, Mar 9, 2011 at 6:00 PM, Rob Kinyon rob.kin...@gmail.com wrote: The as parameter doesn't set the AS keyword in SQL. You want: select = [ 'sym', \'COUNT(*) AS stc_count' ], as = [qw/ stc stc_count /], Rob On Wed, Mar 9, 2011 at 17:49, Dennis Daupert ddaup...@gmail.com wrote: I'm trying to code a simple query in DBIC. I get an error, and don't understand why. What am I doing wrong? QUERY: SELECT sym as stc, count(*) as stc_count FROM i1tickets GROUP BY stc ORDER BY stc_count DESC; CODE: $i1_tic_rs = $schema_pg-resultset('I1tickets')-search( {}, { select = [ 'sym', { count = '*' }, ], as = [qw/ stc stc_count /], group_by = [qw/ stc /], order_by = { -desc = [qw/ stc_count /] }, } ); ROW: while ( $row = $i1_tic_rs-next ) { $stc= $row-stc; $stc_count = $row-stc_count; ERROR: DBIx::Class::ResultSet::next(): DBI Exception: DBD::Pg::st execute failed: ERROR: column stc_count does not exist LINE 1: ...OUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count ... ^ [for Statement SELECT sym, COUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count DESC] I don't see the alias declarations in the error msg... BTW, is there a DBIC helper tool you can feed an sql query and have it spit out Perl code? I could use one ;-) Thanks! ___ 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 -- Thanks, Rob Kinyon ___ 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] Excluding columns from a query
I think -select and -as make sense Justin On Feb 12, 2010 5:18 AM, Nick Wellnhofer wellnho...@aevum.de wrote: On 12.02.2010 04:49, Rob Kinyon wrote: On Thu, Feb 11, 2010 at 17:24, Darren Duncan dar...@darren... Thanks for the tip. I keep forgetting about the usefulness of the grep function. But that doesn't work with prefetch. I think something like this would be handy: $rs-search( undef, { prefetch = 'related', exclude = [ 'me.exclude_me', 'related.exclude_me_too' ], } ); You can also exclude them at the ResultSet level - I leave finding out how as an exerc... What do you mean? Overriding the search method? Nick ___ List: http://lists.scsys.co.uk/cgi-bin/mailman/list... ___ 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] Removing rows older than a given number of minutes ...
shouldn't that be $rs-search({ state = $state, last_modified = *\*[ TIMEDIFF( NOW(), ? SECONDS, $seconds ], })-delete_all; Justin On Tue, Jan 26, 2010 at 2:24 PM, Rob Kinyon rob.kin...@gmail.com wrote: On Tue, Jan 26, 2010 at 16:16, Kiffin Gish kiffin.g...@planet.nl wrote: Very true, but there must be better ways to do this than the reactions so far. What's wrong with: $rs-search({ state = $state, last_modified = [ TIMEDIFF( NOW(), ? SECONDS, $seconds ], })-delete_all; Standard SQL::Abstract stuff, described in both the DBIC cookbook and the SQL::Abstract docs. Remember - date/time manipulation is NOT standardized. Rob ___ 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] NOT IN queries
http://search.cpan.org/dist/SQL-Abstract/lib/SQL/Abstract.pm#Special_operators_:_IN,_BETWEEN,_etc . Justin On Thu, Oct 1, 2009 at 2:26 PM, Dermot paik...@googlemail.com wrote: 2009/10/1 Cory Watson jheep...@gmail.com: On Thu, Oct 1, 2009 at 3:22 PM, Cory Watson jheep...@gmail.com wrote: On Thu, Oct 1, 2009 at 3:18 PM, Dermot paik...@googlemail.com wrote: Hi, I suspect the answer to the question, can I use DBIx::Class::Resultset to do a sql query like this: SELECT * FROM countries where iso2letter NOT IN ('GB','IE', 'HK','US'); Isn't it just: -search({ iso2letter = { '-not-in' = [qw(GB IE HK US)] }) Thanx for putting me straight on that. Is this construct within search() from SQL::Abstract? I can't see it within the DBIx::Class docs. Dp. ___ 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] Loosing data while upgrading from 0.08013 to 0.08101
can you try svn trunk? (http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk/) Justin Emmanuel Quevillon wrote: Re, As nobody answered yet, I probably forgot to include the relation defined into Authors.pm. Here it is if it can help someone to help me :) __PACKAGE__-has_many(pub_auth = 'BiblioListDB::PubAuths', {'foreign.id_auth' = 'self.id_author'}, {cascade_delete = 0}); Please anybody any clue? 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] Re: DBIx-Class Digest, Vol 46, Issue 11
look at http://search.cpan.org/~ribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08099_08/lib/DBIx/Class/ResultSet.pm#for (very bottom) -- Message: 2 Date: Fri, 10 Apr 2009 22:23:36 +0200 From: Andreas Mock andreas.m...@drumedar.de Subject: Re: [Dbix-class] Insert or Update (was ANNOUNCE: 0.08099_08) To: DBIx::Class user and developer list dbix-class@lists.scsys.co.uk Message-ID: 1112748...@web.de Content-Type: text/plain; charset=iso-8859-15 -Ursprungliche Nachricht- Von: Peter Corlett ab...@cabal.org.uk Gesendet: 09.04.09 15:39:05 An: DBIx::Class user and developer list dbix-class@lists.scsys.co.uk Betreff: Re: [Dbix-class] ANNOUNCE: 0.08099_08 (0.08100_RC2) The current implementation does a SELECT followed by an INSERT or UPDATE as appropriate. This introduces a race condition. The whole thing is a critical section and needs to be wrapped in a transaction or savepoint. O.k. I asked why you have to use savepoints, because I thought you can also use transactions. I implemented it by starting a savepoint, then just trying the INSERT. If that fails (normally due to duplicate UNIQUE keys) then the savepoint is rolled back and the SELECT and UPDATE is done as before. After the UPDATE, the savepoint is committed. Why do you have to do a rollback when the update is rejected because of dup key? However, I'm not quite sure this trick completely retains the semantics of create_or_update, so it wouldn't be a drop-in replacement. It would be interesting if you can make it really an atomic operation. I'm asking because I'm not sure if transactions are enough. I also suspect that while savepoints may be necessary, they're not sufficient, and one also needs SELECT FOR UPDATE. How might I express that in DBIC? An interesting question. I would be also interested in that. Best regards Andreas -- ___ DBIx-Class mailing list DBIx-Class@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class End of DBIx-Class Digest, Vol 46, Issue 11 ** ___ 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