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?