Skip Menu |

This queue is for tickets about the SQL-Abstract-More CPAN distribution.

Report information
The Basics
Id: 81341
Status: rejected
Priority: 0/
Queue: SQL-Abstract-More

People
Owner: Nobody in particular
Requestors: jabbas [...] jabbas.pl
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Problems with JOIN
When creating a join, there is no possibility to pass table.field = 'value' into ON(). Is there any possibility to not interpolate (add table alias or table name) to join specification?
To override I can put this in the WHERE section but...
Subject: Re: [rt.cpan.org #81341] Problems with JOIN
Date: Thu, 22 Nov 2012 16:17:17 +0100
To: bug-SQL-Abstract-More [...] rt.cpan.org
From: laurent dami <laurent.dami [...] free.fr>
Le 22.11.2012 14:00, Grzegorz Dzięgielewski via RT a écrit : Show quoted text
> Thu Nov 22 08:00:18 2012: Request 81341 was acted upon. > Transaction: Ticket created by jabbas > Queue: SQL-Abstract-More > Subject: Problems with JOIN > Broken in: (no value) > Severity: Normal > Owner: Nobody > Requestors: jabbas@jabbas.pl > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81341 > > > > When creating a join, there is no possibility to pass table.field = 'value' > into ON(). Is there any possibility to not interpolate (add table alias or > table name) to join specification? > To override I can put this in the WHERE section but... > >
Hi, Unfortunately I don't know how to solve this; the problem is that every join gets transformed into a Perl class, and we can't create a new class for every possible value that would be passed into the ON clause. So indeed, the solution is to put that clause into the WHERE part, i.e. $schema->join(qw/FirstTable path1 path2 .../)->select(-where => {field => $value}); Notice that you can add the WHERE clauses in several steps, maybe that could help solving your needs : my $stmt = $schema->join(qw/FirstTable path1 path2 .../)->select( -where => {field => $value}, -result_as => 'statement', ); # .... more processing my $rows = $statement->refine(-where => {other_field => $other_value})->all; Best regards, Laurent D.
Subject: [rt.cpan.org #81341]
Date: Fri, 30 Nov 2012 19:25:28 +0200
To: bug-sql-abstract-more [...] rt.cpan.org
From: "to.code.perl" <to.code.perl [...] gmail.com>
Hi, following test case will shows you how to add value to ON conditions $join = $sqla->join( 'left', { operator => '<=>', condition => { 'left.requestor' => {-ident => 'right.submitter'}, 'left.requestor2' => {-value => 'some value'}, } }, 'right'); is_same_sql_bind( $join->{sql}, $join->{bind}, "left INNER JOIN right ON ( left.requestor = right.submitter and left.requestor2 = ? )", ['some value'], );
Le Jeu 22 Nov 2012 08:00:18, jabbas a écrit : Show quoted text
> When creating a join, there is no possibility to pass table.field = 'value' > into ON(). Is there any possibility to not interpolate (add table alias or > table name) to join specification? > To override I can put this in the WHERE section but...
I added a new experimental feature -where_on => {table => \%extra_criteria}}. Not released yet on CPAN, but you can have a look at https://github.com/damil/DBIx-DataModel/commit/359b66e15764c51c7760a01b30446993115f215a Feedback welcome
Hum ... sorry, I thought this whole ticket was about DBIx::DataModel, and only now do I realize that this is about SQL::Abstract::More. Within SQL::Abstract::More, you can fine-tune the joins by using the hashref syntax: my %join_cond = (foo => 123, bar => 456); $sqlam->join('table1' => {operator => '=>', condition => \%join_cond} => 'table2); So if you are using SQLAM directtly, you probably already have everything you need. However, if your are using DBIDM, then unfortunately this hashref syntax cannot be used, because of the reasons mentioned earlier in the ticket (every join becomes a Perl class).
Le Jeu 22 Nov 2012 08:00:18, jabbas a écrit : Show quoted text
> When creating a join, there is no possibility to pass table.field = 'value' > into ON().
As stated in my last message, there is indeed a possibility, by using the hashref syntax within join(). So I reject the ticket.