lazy load alias._mailboxes and alias.mailbox
This commit is contained in:
parent
0b652cf3f8
commit
ff1aa72b1d
|
@ -10,6 +10,7 @@ from flask import url_for
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
from sqlalchemy import text, desc, CheckConstraint
|
from sqlalchemy import text, desc, CheckConstraint
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
from sqlalchemy_utils import ArrowType
|
from sqlalchemy_utils import ArrowType
|
||||||
|
|
||||||
from app import s3
|
from app import s3
|
||||||
|
@ -638,10 +639,10 @@ class Alias(db.Model, ModelMixin):
|
||||||
|
|
||||||
# prefix _ to avoid this object being used accidentally.
|
# prefix _ to avoid this object being used accidentally.
|
||||||
# To have the list of all mailboxes, should use AliasInfo instead
|
# To have the list of all mailboxes, should use AliasInfo instead
|
||||||
_mailboxes = db.relationship("Mailbox", secondary="alias_mailbox")
|
_mailboxes = db.relationship("Mailbox", secondary="alias_mailbox", lazy="joined")
|
||||||
|
|
||||||
user = db.relationship(User)
|
user = db.relationship(User)
|
||||||
mailbox = db.relationship("Mailbox")
|
mailbox = db.relationship("Mailbox", lazy="joined")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mailboxes(self):
|
def mailboxes(self):
|
||||||
|
|
Loading…
Reference in a new issue