Check for "postgresql*" rather than just "postgresql" in
HashField.db_type() so that postgresql_psycopg2 will work.
While we're here, raise an exception if the database engine is
unknown rather than silently not returning anything.
Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
n_bytes = len(hashlib.new(self.algorithm).digest())
else:
n_bytes = len(self.hash_constructor().digest())
- if settings.DATABASE_ENGINE == 'postgresql':
+ if settings.DATABASE_ENGINE.startswith('postgresql'):
return 'bytea'
elif settings.DATABASE_ENGINE == 'mysql':
return 'binary(%d)' % n_bytes
+ else:
+ raise Exception("Unknown database engine '%s'" % \
+ settings.DATABASE_ENGINE)
def to_python(self, value):
return value