Multiple conditions for a fixture

I’m using ERPNext v16.

I would like to include all the Print Formats which contain “AST” or end in “ (test)” as part of my fixtures in hooks.py. I can’t work out the correct format to do this however.

At first I tried including the two conditions as separate lines:

fixtures = [
    {"dt": "Print Format", "filters": {"name": ["like", "%AST%"]}},
    {"dt": "Print Format", "filters": {"name": ["like", "% (test)"]}},
]

But this only included the formats which ended in “ (test)”.

I saw somewhere suggest that in can take multiple parameters:

fixtures = [
    {"dt": "Print Format", "filters": {"name": ["in", ("%AST%", "% (test)")]}},
]

But that included nothing so mustn’t be correct.

AI suggested using regex:

fixtures = [
    {"dt": "Print Format", "filters": {"name": ["regex", r".*\bAST\b.*|.+ \(test\)$"]}},
]

But various combinations of escaping backlashes or character sets:

fixtures = [
    {"dt": "Print Format", "filters": {"name": ["regex", ".*[[:<:]]AST[[:>:]].*|.+ [(]test[)]$"]}},
]

All resulted in a MySQLdb.ProgrammingError:

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'REGEX '.*\\\\bAST\\\\b.*|.+ \\\\(test\\\\)%' ORDER BY `idx` ASC,`creation` ASC' at line 1")
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'REGEX '.*[[:<:]]AST[[:>:]].*|.+ [(]test[)]$' ORDER BY `idx` ASC,`creation` ASC' at line 1")

I think it may be a hallucination about Frappe supporting regex as an operator at all. I certainly couldn’t find the code that would construct the query.

AI nonsense aside, how do you have multiple conditions for a fixture joined by an OR rather than an AND?

No further forward with a solution, but I have learnt some things on the way.

in obviously takes multiple parameters, but all as fixed strings. There is no wildcard matching using %.

Looks like the AI was correct in that Frappe does support regex as a filter operator, just not in a way that it must ever have worked:

For filtering with a regex, MySQL and MariaDB both use RLIKE or REGEXP, and PostgreSQL uses ~. I don’t know which database uses REGEX. This much looks like a Frappe bug.