Skip to content

Commit

Permalink
Change '-funcall' to '-func'.
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Dec 13, 2010
1 parent 75db176 commit 700c3d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/SQL/Abstract.pm
Expand Up @@ -22,17 +22,17 @@ $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev relea

our $AUTOLOAD;

my @_funcall_ops =
my @_func_ops =
(
{regex => qr/^ funcall $/ix, handler => '_where_field_FUNCALL'},
{regex => qr/^ func $/ix, handler => '_where_field_FUNC'},
);

# special operators (-in, -between). May be extended/overridden by user.
# See section WHERE: BUILTIN SPECIAL OPERATORS below for implementation
my @BUILTIN_SPECIAL_OPS = (
{regex => qr/^ (?: not \s )? between $/ix, handler => '_where_field_BETWEEN'},
{regex => qr/^ (?: not \s )? in $/ix, handler => '_where_field_IN'},
@_funcall_ops,
@_func_ops,
);

# unaryish operators - key maps to handler
Expand All @@ -42,7 +42,7 @@ my @BUILTIN_UNARY_OPS = (
{ regex => qr/^ or (?: [_\s]? \d+ )? $/xi, handler => '_where_op_ANDOR' },
{ regex => qr/^ nest (?: [_\s]? \d+ )? $/xi, handler => '_where_op_NEST' },
{ regex => qr/^ (?: not \s )? bool $/xi, handler => '_where_op_BOOL' },
@_funcall_ops,
@_func_ops,
);

#======================================================================
Expand Down Expand Up @@ -937,7 +937,7 @@ sub _where_field_BETWEEN {
return ($sql, @bind)
}

sub _where_field_FUNCALL {
sub _where_field_FUNC {
my ($self, $k, $vals) = @_;

my $label = $self->_convert($self->_quote($k));
Expand All @@ -950,10 +950,10 @@ sub _where_field_FUNCALL {
($s, @b);
},
SCALARREF => sub {
puke "special op 'funcall' accepts an arrayref with more than one value."
puke "special op 'func' accepts an arrayref with more than one value."
},
ARRAYREF => sub {
puke "special op 'funcall' accepts an arrayref with more than one value."
puke "special op 'func' accepts an arrayref with more than one value."
if @$vals < 1;

my (@all_sql, @all_bind);
Expand All @@ -962,7 +962,7 @@ sub _where_field_FUNCALL {

if ($func =~ m{\W})
{
puke "Function in -funcall may only contain alphanumeric characters.";
puke "Function in -func may only contain alphanumeric characters.";
}

foreach my $val (@rest_of_vals) {
Expand Down Expand Up @@ -996,7 +996,7 @@ sub _where_field_FUNCALL {
);
},
FALLBACK => sub {
puke "special op 'funcall' accepts an arrayref with two values, or a single literal scalarref/arrayref-ref";
puke "special op 'func' accepts an arrayref with two values, or a single literal scalarref/arrayref-ref";
},
});

Expand Down Expand Up @@ -2243,12 +2243,12 @@ Would give you:
These are the two builtin "special operators"; but the
list can be expanded : see section L</"SPECIAL OPERATORS"> below.
Another operator is C<-funcall> that allows you to call SQL functions with
Another operator is C<-func> that allows you to call SQL functions with
arguments. It receives an array reference containing the function name
as the 0th argument and the other arguments being its parameters. For example:
my %where = {
-funcall => ['substr', 'Hello', 50, 5],
-func => ['substr', 'Hello', 50, 5],
};
Would give you:
Expand Down
2 changes: 1 addition & 1 deletion t/01generate.t
Expand Up @@ -533,7 +533,7 @@ my @tests =
{
func => 'select',
args => ['jeff', '*',
{ '-funcall' => ['substr', 1010, 5, 6,], },
{ '-func' => ['substr', 1010, 5, 6,], },
],
stmt => 'SELECT * FROM jeff WHERE (substr(?, ?, ?))',
stmt_q => 'SELECT * FROM `jeff` WHERE (substr(?, ?, ?))',
Expand Down

0 comments on commit 700c3d9

Please sign in to comment.