Skip to content

FIND_IN_SET to PATINDEX translation missing %s #339

@rmc47

Description

@rmc47

At the moment, the FIND_IN_SET translation (used by bbPress's topic subscription notifications) turns into PATINDEX:
https://github.com/ProjectNami/projectnami/blob/master/wp-includes/translations.php#L1151

However, the pattern argument isn't surrounded by %s, which https://docs.microsoft.com/en-us/sql/t-sql/functions/patindex-transact-sql suggests it must be, so returns no results:

SELECT PATINDEX(',456,',',123,456,789,')
-- returns 0

SELECT PATINDEX('%,456,%',',123,456,789,')
-- returns 5

I'll submit a PR to fix this, but @LitKnd pointed out that since SQL 2016, there's the rather nice STRING_SPLIT function which might offer a neater solution. What's your feeling on how many folks would be hit by upping the current SQL 2012 requirement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions