MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_cast

Method visit_cast

lib/sqlalchemy/dialects/oracle/base.py:1351–1366  ·  view source on GitHub ↗
(self, cast, **kwargs)

Source from the content-addressed store, hash-verified

1349 return "0"
1350
1351 def visit_cast(self, cast, **kwargs):
1352 # Oracle requires VARCHAR2 to have a length in CAST expressions
1353 # Adapt String types to VARCHAR2 with appropriate length
1354 type_ = cast.typeclause.type
1355 if isinstance(type_, sqltypes.String) and not isinstance(
1356 type_, (sqltypes.Text, sqltypes.CLOB)
1357 ):
1358 adapted = VARCHAR2._adapt_string_for_cast(type_)
1359 type_clause = self.dialect.type_compiler_instance.process(adapted)
1360 else:
1361 type_clause = cast.typeclause._compiler_dispatch(self, **kwargs)
1362
1363 return "CAST(%s AS %s)" % (
1364 cast.clause._compiler_dispatch(self, **kwargs),
1365 type_clause,
1366 )
1367
1368 def get_cte_preamble(self, recursive):
1369 return "WITH"

Callers

nothing calls this directly

Calls 3

processMethod · 0.45
_compiler_dispatchMethod · 0.45

Tested by

no test coverage detected