Re: [CDBI] Using scalar functions with AbstractSearch

[prev] [thread] [next] [Date index for 2006/02/02]

From: Bill Moseley
Subject: Re: [CDBI] Using scalar functions with AbstractSearch
Date: 04:16 on 02 Feb 2006
On Thu, Feb 02, 2006 at 02:41:57AM +0100, Rhesa Rozendaal wrote:
> >$ perl -MData::Dumper -MSQL::Abstract -le "print Dumper 
> >[SQL::Abstract->new->where( { foo => 'bar', start => {'<', 'now()'}, end 
> >=> { '>=', 'now()'} } )]"
> >$VAR1 = [
> >          ' WHERE ( end >= ? AND foo = ? AND start < ? )',
> >          'now()',
> >          'bar',
> >          'now()'
> >        ];
> 
> Close, but no sigar ;)

> That way makes the "now()" just a plain string, whereas I was looking for 
> the database function now() [might be mysql specific]. The resulting SQL 
> would be:
> 
>  WHERE ( end >= 'now()' AND foo = 'bar' AND start < 'now()' )
> 
> which is different from
> 
>  WHERE ( end >= now() AND foo = 'bar' AND start < now() )


You must be smoking different cigars:

(or using a different DBD)


test=> \d times
                                     Table "public.times"
 Column |            Type             |                       Modifiers                       
--------+-----------------------------+-------------------------------------------------------
 id     | integer                     | not null default nextval('public.times_id_seq'::text)
 name   | text                        | 
 time   | timestamp(0) with time zone | 
Indexes:
    "times_pkey" primary key, btree (id)

test=> select * from times;
 id | name  |          time          
----+-------+------------------------
  1 | hello | 2006-02-01 20:10:53-08
(1 row)


$ cat now.pl
package DB;
use base 'Class::DBI::Sweet';
DB->connection('dbi:Pg:dbname=test');

package DB::Time;
use base 'DB';
__PACKAGE__->table('times');
__PACKAGE__->columns(All => qw/id time name/);


package main;
use strict;
use warnings;


my $foo = DB::Time->search( {
    time => { '<=', 'now()' },
})->first;

print $foo->time;

$ perl -l now.pl
2006-02-01 20:10:53-08


        -- 
        Bill Moseley
moseley@xxxx.xxx


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

[CDBI] Using scalar functions with AbstractSearch
Dylan Vanderhoof 23:37 on 01 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Rhesa Rozendaal 23:50 on 01 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Rhesa Rozendaal 00:07 on 02 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Rhesa Rozendaal 01:41 on 02 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Bill Moseley 04:16 on 02 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Rhesa Rozendaal 04:54 on 02 Feb 2006

[CDBI] Re: Using scalar functions with AbstractSearch
Edward J. Sabol 05:16 on 02 Feb 2006

Re: [CDBI] Using scalar functions with AbstractSearch
Tatsuhiko Miyagawa 05:33 on 02 Feb 2006

RE: [CDBI] Using scalar functions with AbstractSearch
Dylan Vanderhoof 05:29 on 02 Feb 2006

Generated at 17:59 on 03 Feb 2006 by mariachi v0.52