| 258 | |
| 259 | |
| 260 | class Reverse(Transform): |
| 261 | function = "REVERSE" |
| 262 | lookup_name = "reverse" |
| 263 | |
| 264 | def as_oracle(self, compiler, connection, **extra_context): |
| 265 | # REVERSE in Oracle is undocumented and doesn't support multi-byte |
| 266 | # strings. Use a special subquery instead. |
| 267 | suffix = connection.features.bare_select_suffix |
| 268 | sql, params = super().as_sql( |
| 269 | compiler, |
| 270 | connection, |
| 271 | template=( |
| 272 | "(SELECT LISTAGG(s) WITHIN GROUP (ORDER BY n DESC) FROM " |
| 273 | f"(SELECT LEVEL n, SUBSTR(%(expressions)s, LEVEL, 1) s{suffix} " |
| 274 | "CONNECT BY LEVEL <= LENGTH(%(expressions)s)) " |
| 275 | "GROUP BY %(expressions)s)" |
| 276 | ), |
| 277 | **extra_context, |
| 278 | ) |
| 279 | return sql, params * 3 |
| 280 | |
| 281 | |
| 282 | class Right(Left): |
no outgoing calls