From 67ee1d0dc9148d82798b7a89de6e32aad825b88a Mon Sep 17 00:00:00 2001 From: Markus Kaiserswerth Date: Mon, 28 Jul 2014 15:32:44 +0200 Subject: [PATCH] PasswordType: use RAW impl for Oracle instead of non-existent VARBINARY If I'm not mistaken, the Oracle SQL DB (at least 11g R2) doesn't have a VARBINARY type. This fix uses a RAW (binary) type instead for the Oracle dialect. --- sqlalchemy_utils/types/password.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index d8034e4..c2a03d0 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -2,7 +2,7 @@ import six import weakref from sqlalchemy_utils import ImproperlyConfigured from sqlalchemy import types -from sqlalchemy.dialects import postgresql +from sqlalchemy.dialects import postgresql, oracle from .scalar_coercible import ScalarCoercible from sqlalchemy.ext.mutable import Mutable @@ -115,8 +115,6 @@ class PasswordType(types.TypeDecorator, ScalarCoercible): """ - impl = types.VARBINARY(1024) - python_type = Password def __init__(self, max_length=None, **kwargs): @@ -159,6 +157,10 @@ class PasswordType(types.TypeDecorator, ScalarCoercible): # Use a BYTEA type for postgresql. impl = postgresql.BYTEA(self.length) return dialect.type_descriptor(impl) + if dialect.name == 'oracle': + # Use a RAW type for oracle. + impl = oracle.RAW(self.length) + return dialect.type_descriptor(impl) # Use a VARBINARY for all other dialects. impl = types.VARBINARY(self.length)