<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Search::Query::Field::SQL;
use Moo;
extends 'Search::Query::Field';

use namespace::autoclean;

has 'type'         =&gt; ( is =&gt; 'rw' );
has 'fuzzy_op'     =&gt; ( is =&gt; 'rw' );
has 'fuzzy_not_op' =&gt; ( is =&gt; 'rw' );
has 'is_int'       =&gt; ( is =&gt; 'rw' );

our $VERSION = '0.306';

=head1 NAME

Search::Query::Field::SQL - query field representing a database column

=head1 SYNOPSIS

 my $field = Search::Query::Field::SQL-&gt;new( 
    name        =&gt; 'foo',
    alias_for   =&gt; [qw( bar bing )], 
 );

=head1 DESCRIPTION

Search::Query::Field::SQL implements field
validation and aliasing in SQL search queries.

=head1 METHODS

This class is a subclass of Search::Query::Field. Only new or overridden
methods are documented here.

=head2 BUILD

Available params are also standard attribute accessor methods.

=over

=item type

The column type.

=item fuzzy_op

=item fuzzy_not_op

=item is_int

Set if C&lt;type&gt; matches m/int|float|bool|time|date/.

=back

=cut

sub BUILD {
    my $self = shift;

    $self-&gt;{type} ||= 'char';

    # numeric types
    if ( $self-&gt;{type} =~ m/int|float|bool|time|date/ ) {
        $self-&gt;{fuzzy_op}     ||= '&gt;=';
        $self-&gt;{fuzzy_not_op} ||= '! &gt;=';
        $self-&gt;{is_int} = 1;
    }

    # text types
    else {
        $self-&gt;{fuzzy_op}     ||= 'ILIKE';
        $self-&gt;{fuzzy_not_op} ||= 'NOT ILIKE';
        $self-&gt;{is_int} = 0;
    }

}

1;
</pre></body></html>