Re: [Dbix-class] ANNOUNCE: SQL::Abstract 1.60

2009-09-22 Thread Peter Rabbitson
Peter Rabbitson wrote:
 Will Hawes wrote:
 Ah - I had expected the following to work, but it doesn't:

 my $where = {
 datetime = {
 between,
 [
 \[ to_date(?, 'MMDD HH24:MM:SS'), $start 00:00:00 ],
 \[ to_date(?, 'MMDD HH24:MM:SS'), $end 00:00:00 ]
 ]
 }
 };

 It seems that while a reference to an arrayref can be used with
 between, elements within said arrayref are currently limited to
 either scalars or references to scalars. Maybe a candidate for a
 patch?

 
 SQL::Abstract 1.59 just released on CPAN should nicely support all
 combinations of the above.
 

And SQL::Abstract 1.60 follows suit, as changes to the tester exposed subtle
problems with the tokenizer (no functional changes between 1.59 and 1.60).

___
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] Filtering with Many-to-Many relationship

2009-09-22 Thread Wallace Reis
On Tue, Sep 22, 2009 at 7:23 AM, Oleg Kostyuk cub.ua...@gmail.com wrote:
 I think, you just need to join twice with tags table, and this will
 give you what you want:

And if you need products which have 3 or more tags? One join per tag?
It is not ideal.

-- 
 wallace reis/wreis Catalyst and DBIx::Class consultancy with a clue
 Software Engineer  and a commit bit: 
http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
 http://www.shadowcat.co.uk http://www.linkedin.com/in/wallacereis

___
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] Possible error in DBIx::Class::TimeStamp

2009-09-22 Thread Oleg Kostyuk
From time of last writing, we have three (!) releases - 0.08110,
0.08111, 0.08112 - but patches is still not applied. Do we have some
reason for this?...

Thanks.

-- 
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)

___
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] ANNOUNCE: SQL::Abstract 1.60

2009-09-22 Thread Karen Hoofnagle
As of SQL::Abstract 1.60, the following code now properly supports  
using functions with between.


my $rs = $schema-resultset('User_Read_Log')-search(
{
   datetime = {
   between,
   [
   \[ to_date(?, 'MMDD HH24:MI:SS'), $start 00:00:00 ],
   \[ to_date(?, 'MMDD HH24:MI:SS'), $end 00:00:00 ]
   ]
   }

Thanks so much Peter and Will and everyone who responded. I'll see  
about propagating this example to the cookbook.

Karen

___
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] Filtering with Many-to-Many relationship

2009-09-22 Thread Matt Whipple

Shawn Marincas wrote:
It seems that the above query won't work in any case since searching 
for tag_id IN a set will still returned the results OR'd together, and 
I need the set of products which contain BOTH tags.  I've been toying 
with it some more and came up with a solution which uses a subquery, 
still not sure if this is the optimum solution yet or not.
If you're worried about optimization, the one thing I would watch for is 
to ensure that the DBMS is still able to optimize the subquery by 
determining the most restrictive initial set of data, or otherwise 
implementing that optimization manually.  With something like tags I 
would assume that some are far more general than others so this could 
have a significant impact.  This is something that would normally occur 
with a self-join, but a subquery is likely a more fitting solution in 
your case. 

I may also suggest coupling this with a digest form of the tags (similar 
to a SET data type) which can then be run through a bitwise AND.  This 
would require organizing the tags (possibly into word-sized categories) 
but should allow for very quick checks that wouldn't add overhead as 
searches grew more complex.


$filtered_product_rs = $schema-resultset('Product')-search({
'product_tags.tag_id' = $tag2_rs-tag_id,
'me.product_id' = {
-in = [
$schema-resultset('Product')-search_rs({
'product_tags.tag_id' = $tag_rs-tag_id
},{
join = 'product_tags'
})-get_column('product_id')-all
]
}
}, {
join= 'product_tags'
});


On Fri, Sep 18, 2009 at 7:35 PM, Wallace Reis reis.wall...@gmail.com 
mailto:reis.wall...@gmail.com wrote:


On Fri, Sep 18, 2009 at 3:06 PM, Shawn Marincas
shawngmarin...@gmail.com mailto:shawngmarin...@gmail.com wrote:
 I have a table Products and a table Tags with a many_to_many
relationship
 setup, the purpose of which would be to easily generate a
resultset of
 products with the given tag(s).  However, I'm running in to
problems when I
 want to generate a resultset of product records filtered with
multiple
 tags.  I was thinking that one of the following would work:

 my $tag1 = 'A';
 my $tag2 = 'B';

my $product_rs = $schema-resultset('Product')-search_rs({
   'tag.tag_id' = { -in = [qw/A B/] }
}, {
   join = { 'product_tags' = 'tag' }
});

 But apparently the many_to_many relationship accessor only
returns a list of
 row_objects rather than a resultset itself, so I can't perform
resultset
 searches on that.  So I tried the following to chain together
two searches:

You've used the -search method in your code in list context, so it
calls -all over the resultset and returns a list of row objects.

--
wallace reis/wreis Catalyst and DBIx::Class
consultancy with a clue
Software Engineer  and a commit bit:
http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
 http://www.shadowcat.co.uk http://www.linkedin.com/in/wallacereis

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class http://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] Group By statistics columns

2009-09-22 Thread Matt Whipple

Trevor Phillips wrote:

2009/9/21 Андрей Костенко and...@kostenko.name:
  

You can create a view for this query. e.g.
CREATE VIEW stats AS SELECT MIN(a), MAX(a), AVG(a) FROM table1;



I could, but it's not the query I'm having a problem with - it's
mapping it to columns within the pre-existing DBIx::Class. I'd rather
not have to create a whole new class simply for this single query
against my data. I can see the data in the raw object - I just can't
access it through the normal methods.

Reading the manual, I should be able to get the value via get_column,
but Catalyst/TT uses the column methods instead.

Hmmm, I *can* use get_column within TT, but that seems to defeat the
purpose of abstracting data from presentation.
  
You could leave the accessor abstracted by creating the function within 
the result class.  Along the lines of

sub a_min { return shift-get_column('a_min'); };

When getting the search results, I can map the rows with
$_-get_columns(). That seems to be the easiest solution for now.

--
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] Possible error in DBIx::Class::TimeStamp

2009-09-22 Thread Oleg Kostyuk
Sure, DBIx::Class::TimeStamp shipped separately. But as I understood,
fREW Schmidt told about failing tests in DBIx::Class. I think so
because on time of writing my email with patches he confirmed at IRC
(not to me, but to Ralf - I just see this) that all tests in
DBIx::Class::TimeStamp is passed ok with my patches applied. And so,
now I'm told about releases of DBIx::Class itself - if it was
released, then all troubles was fixed, isn't? - but patches to
DBIx::Class::TimeStamp is still not committed.

2009/9/22 Brian Cassidy brian.cass...@gmail.com:
 On Tue, Sep 22, 2009 at 2:12 PM, Oleg Kostyuk cub.ua...@gmail.com wrote:
 From time of last writing, we have three (!) releases - 0.08110,
 0.08111, 0.08112 - but patches is still not applied. Do we have some
 reason for this?...

 Forgive me if I'm talking out of turn, but, weren't your patches for
 DBIx::Class::TimeStamp ...which is shipped separately from
 DBIx::Class.

-- 
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)

___
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