[Dbix-class] [PATCH] allow non-columns to be passed in joinsusing the from a

brett gardner brett at clientcomm.com.au
Thu Sep 21 02:33:40 CEST 2006


Just yesterday I had to put a similar fix in because I had to do a 
custom join to a table subset with an is null condition ie

'ON (article_content.module_id = modules.module_id AND 
article_content.level_id IS NULL)'

On a side note, does anyone know how to do a 'IS NOT NULL' in a where 
clause without having to use a scalar ref?

eg

field=>undef

produces 'me.field IS NULL'

So is there an easy way to produce

'me.field IS NOT NULL'

Brett

mike wrote:
> On 9/20/06, Robert Dobbs <bobisdobbs at hotmail.com> wrote:
>   
>>> From: mike <pulsation at gmail.com>
>>> Date: Wed, 20 Sep 2006 18:22:42 -0500
>>>
>>>   LEFT JOIN `authorizations` `authorizations` ON (
>>> `authorizations`.`product_id` = `me`.`product_id` AND
>>> `authorizations.active` = 1 )
>>>
>>> the affected part is the second condition for the JOIN.  without this
>>> patch, the 1 is quoted as `1`, which is undesired.  with the patch,
>>> passing the 1 as a scalar reference allows it to be passed unquoted.
>>> the associated search construct is:
>>>
>>> $rs->search
>>> (
>>>     {
>>>         'me.publisher_id'                   => $publisher->id,
>>>         'me.active'                         => 1,
>>>         'authorizations.authorization_id'   => undef
>>>     },
>>>       
>> Isn't it supposed to figure out on its own whether to quote or not based on
>> the field type in the schema?
>>     
>
> quoting with backticks in mysql designates the enclosed value as an
> identifier; thus, quoting the value in this example with a backtick,
> regardless of field type, would be incorrect behavior.
>
> i am fairly certain that the "don't quote if scalar ref" behavior that
> is supported for where conditions simply isn't implemented for
> join_condition due to lack of usage.  most are likely to not be using
> the custom from stuff for joins not directly comparing two columns.
>
> but i could be wrong.
>
> -mike
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
>
>   



More information about the Dbix-class mailing list