Extracts and returns the name of this query from a '-- name: {name}' comment. Returns 'anonymous' if the name is not set.
(self)
| 35 | return self.query |
| 36 | |
| 37 | def name(self) -> str: |
| 38 | """Extracts and returns the name of this query from a '-- name: {name}' comment. |
| 39 | Returns 'anonymous' if the name is not set.""" |
| 40 | p = r"-- name\: (?P<name>.+)" |
| 41 | m = re.search(p, self.query, re.MULTILINE) |
| 42 | return m.group("name") if m else "anonoymous" |
| 43 | |
| 44 | def explain(self, timing: bool, dialect: Dialect = Dialect.MZ) -> str: |
| 45 | """Prepends 'EXPLAIN ...' to the query respecting the given dialect.""" |