}
croak 'args to -dt_get must be an arrayref' unless ref $vals eq 'ARRAY';
- croak 'first arg to -dt_get must be a scalar' unless !ref $vals->[0];
+ croak 'first arg to -dt_get must be a scalar or ARRAY ref' unless !ref $vals->[0] || ref $vals->[0] eq 'ARRAY';
my $part = $vals->[0];
my $val = $vals->[1];
}
});
- return $self->_datetime_sql($part, $sql), @bind;
+ if (!ref $part) {
+ return $self->_datetime_sql($part, $sql), @bind;
+ } elsif (ref $part eq 'ARRAY' ) {
+ return ( join ', ', map { $self->_datetime_sql($_, $sql) } @$part ), (@bind) x @$part;
+ }
}
for my $part (qw(month year hour minute second)) {
['2010-12-12', '2011-12-14 12:12:12.000', '2011-12-12 12:12:12.000'],
]) if $schema{mssql}->storage->connected;
-#my %sql_maker = map { $_ => $schema{$_}->storage->sql_maker } keys %schema;
-
my $date = DateTime->new(
year => 2010,
month => 12,
{
search => { 'me.id' => 1 },
+ select => [ [ -dt_get => [[qw(year month)], { -ident => 'me.created_on' }] ] ],
+ as => [ qw(year month) ],
+ mssql => {
+ select => "DATEPART(year, me.created_on), DATEPART(month, me.created_on)",
+ where => "me.id = ?",
+ bind => [['me.id' => 1 ]],
+ hri => [{ year => 2010, month => 12 }],
+ },
+ sqlite => {
+ select => "STRFTIME('%Y', me.created_on), STRFTIME('%m', me.created_on)",
+ where => "me.id = ?",
+ bind => [['me.id' => 1 ]],
+ hri => [{ year => 2010, month => 12 }],
+ },
+ msg => '-dt_get (year, month) works',
+ },
+
+ {
+ search => { 'me.id' => 1 },
select => [ [ -dt_month => { -ident => 'me.created_on' } ] ],
as => [ 'month' ],
sqlite => {