MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / VARCHAR2

Class VARCHAR2

lib/sqlalchemy/dialects/oracle/types.py:40–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40class VARCHAR2(VARCHAR):
41 __visit_name__ = "VARCHAR2"
42
43 @classmethod
44 def _adapt_string_for_cast(cls, type_: sqltypes.String) -> "VARCHAR2":
45 """Adapt a String type for use in CAST expressions.
46
47 Oracle requires a length for VARCHAR2 in CAST expressions.
48 If no length is specified, we default to 4000 (max for VARCHAR2).
49 """
50 type_ = sqltypes.to_instance(type_)
51 if isinstance(type_, VARCHAR2):
52 return type_
53 elif isinstance(type_, VARCHAR):
54 return VARCHAR2(
55 length=type_.length or 4000, collation=type_.collation
56 )
57 else:
58 return VARCHAR2(length=type_.length or 4000)
59
60
61NVARCHAR2 = NVARCHAR

Callers 3

test_string_typesMethod · 0.90
dictionary.pyFile · 0.85

Calls

no outgoing calls

Tested by 1

test_string_typesMethod · 0.72