Skip to content

Placeholder-Validation errors on multi-line query #336

@staabm

Description

@staabm

running a query like

$queryString = '

            SELECT
                land.*,
                COALESCE(NULLIF(landsprache.ort, ""), land.ort) AS ort
            FROM land
                INNER JOIN landsprache ON (land.landid=landsprache.landid and landsprache.spracheid = ?)
            WHERE (webinaktiv = 0) ORDER BY COALESCE(NULLIF(landsprache.ort, ""), land.ort) ASC
';

thru

if (preg_match_all(self::REGEX_UNNAMED_PLACEHOLDER, $queryString, $matches) > 0) {
$candidates = $matches[0];
// filter placeholders within quoted strings
$candidates = array_filter($candidates, function ($candidate) {
return '"' !== $candidate[0] && "'" !== $candidate[0];
});
return \count($candidates);
}

does not return 1 as the number of matched placeholders

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions