| 38 | |
| 39 | |
| 40 | class 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 | |
| 61 | NVARCHAR2 = NVARCHAR |
no outgoing calls