Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong test case for !n #5

Open
bokutin opened this issue Apr 6, 2023 · 0 comments
Open

Wrong test case for !n #5

bokutin opened this issue Apr 6, 2023 · 0 comments

Comments

@bokutin
Copy link

bokutin commented Apr 6, 2023

my $rs_query = Person->search_rs( $parser->parse('!n')->as_dbic_query );

% sqd '!n'
!n
 => -n

% perl -E 'use Search::Query; say Search::Query->parser( default_field => [qw(name email)], fields => [qw(name email)], dialect => "SQL" )->parse("!n")'
NOT (name='n' OR email='n')

my $rs_expected = Person->search_rs(
[ \[ "COALESCE( LOWER(name), '' ) NOT LIKE ?",
[ plain_value => "%n%" ]
],
\[ "COALESCE( LOWER(email), '' ) NOT LIKE ?",
[ plain_value => "%n%" ]
],
]
);

above $rs_expected->count is 4.
The same query as "NOT (name='n' OR email='n')" could be the following.

my $rs_expected = Person->search_rs(
    {
        -not => {
            -or => [
                \[  "COALESCE( LOWER(name), '' ) LIKE ?",
                    [ plain_value => "%n%" ]
                ],
                \[  "COALESCE( LOWER(email), '' ) LIKE ?",
                    [ plain_value => "%n%" ]
                ],
            ]
        }
    ]
);

above $rs_expected->count is 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant