Created function for returning email type

master
Ionut Filip 6 years ago
parent 47a3fd47b5
commit 436055f02c

@ -21,6 +21,11 @@ import dns
db = flask_sqlalchemy.SQLAlchemy() db = flask_sqlalchemy.SQLAlchemy()
config = configuration.ConfigManager() config = configuration.ConfigManager()
def email_type():
if config['DB_FLAVOR'] == 'postgresql':
return CIText()
else:
return db.String(255, collation="NOCASE")
class IdnaDomain(db.TypeDecorator): class IdnaDomain(db.TypeDecorator):
""" Stores a Unicode string in it's IDNA representation (ASCII only) """ Stores a Unicode string in it's IDNA representation (ASCII only)
@ -58,9 +63,6 @@ class IdnaEmail(db.TypeDecorator):
idna.decode(domain_name), idna.decode(domain_name),
) )
def __init__(self):
if config['DB_FLAVOR'] == 'postgresql':
self.impl = CIText()
class CommaSeparatedList(db.TypeDecorator): class CommaSeparatedList(db.TypeDecorator):
@ -443,7 +445,7 @@ class Fetch(Base):
__tablename__ = "fetch" __tablename__ = "fetch"
id = db.Column(db.Integer(), primary_key=True) id = db.Column(db.Integer(), primary_key=True)
user_email = db.Column(db.String(255), db.ForeignKey(User.email), user_email = db.Column(email_type(), db.ForeignKey(User.email),
nullable=False) nullable=False)
user = db.relationship(User, user = db.relationship(User,
backref=db.backref('fetches', cascade='all, delete-orphan')) backref=db.backref('fetches', cascade='all, delete-orphan'))

Loading…
Cancel
Save