Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SQLA 1.4 warning #477

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ class BibNoms(db.Model):
comments = db.Column(db.Unicode)

taxref = db.relationship("Taxref", back_populates="bib_nom")
attributs = db.relationship("CorTaxonAttribut")
listes = db.relationship("CorNomListe")
attributs = db.relationship("CorTaxonAttribut", back_populates="bib_nom")
listes = db.relationship("CorNomListe", back_populates="bib_nom")
# medias relationship defined through backref

def __repr__(self):
return f"<BibNoms {self.nom_francais}>"


@serializable
class CorTaxonAttribut(db.Model):
Expand All @@ -45,11 +48,11 @@ class CorTaxonAttribut(db.Model):
primary_key=True,
)
valeur_attribut = db.Column(db.Text, nullable=False)
bib_nom = db.relationship("BibNoms")
bib_nom = db.relationship("BibNoms", back_populates="attributs")
bib_attribut = db.relationship("BibAttributs")

def __repr__(self):
return "<CorTaxonAttribut %r>" % self.valeur_attribut
return f"<CorTaxonAttribut {self.valeur_attribut}>"


@serializable
Expand All @@ -61,10 +64,10 @@ class BibThemes(db.Model):
desc_theme = db.Column(db.Unicode)
ordre = db.Column(db.Integer)
id_droit = db.Column(db.Integer)
attributs = db.relationship("BibAttributs", lazy="select")
attributs = db.relationship("BibAttributs", lazy="select", back_populates="theme")

def __repr__(self):
return "<BibThemes %r>" % self.nom_theme
return f"<BibThemes {self.nom_theme}>"


@serializable
Expand All @@ -88,10 +91,10 @@ class BibAttributs(db.Model):
primary_key=False,
)
ordre = db.Column(db.Integer)
theme = db.relationship(BibThemes)
theme = db.relationship(BibThemes, back_populates="attributs")

def __repr__(self):
return "<BibAttributs %r>" % self.nom_attribut
return f"<BibAttributs {self.nom_attribut}>"


@serializable(exclude=["nom_vern_or_lb_nom"])
Expand Down Expand Up @@ -125,7 +128,7 @@ class Taxref(db.Model):
group3_inpn = db.Column(db.Unicode)
url = db.Column(db.Unicode)

bib_nom = db.relationship("BibNoms", back_populates="taxref")
bib_nom = db.relationship(BibNoms, back_populates="taxref")

@hybrid_property
def nom_vern_or_lb_nom(self):
Expand All @@ -136,7 +139,7 @@ def nom_vern_or_lb_nom(cls):
return db.func.coalesce(cls.nom_vern, cls.lb_nom)

def __repr__(self):
return "<Taxref %r>" % self.nom_complet
return f"<Taxref {self.nom_complet}>"


@serializable
Expand All @@ -155,11 +158,11 @@ class CorNomListe(db.Model):
nullable=False,
primary_key=True,
)
bib_nom = db.relationship("BibNoms")
bib_liste = db.relationship("BibListes")
bib_nom = db.relationship(BibNoms, back_populates="listes")
bib_liste = db.relationship("BibListes", back_populates="cnl")

def __repr__(self):
return "<CorNomListe %r>" % self.id_liste
return f"<CorNomListe {self.id_liste}>"


@serializable
Expand All @@ -174,11 +177,13 @@ class BibListes(db.Model):
regne = db.Column(db.Unicode)
group2_inpn = db.Column(db.Unicode)

cnl = db.relationship("CorNomListe", lazy="select")
noms = db.relationship("BibNoms", secondary=CorNomListe.__table__)
cnl = db.relationship(CorNomListe, lazy="select", back_populates="bib_liste")
noms = db.relationship(
"BibNoms", secondary=CorNomListe.__table__, overlaps="bib_nom,listes,bib_liste,cnl"
)

def __repr__(self):
return "<BibListes %r>" % self.nom_liste
return f"<BibListes {self.nom_liste}>"


@serializable
Expand All @@ -190,7 +195,7 @@ class BibTypesMedia(db.Model):
desc_type_media = db.Column(db.Text)

def __repr__(self):
return "<BibTypesMedia %r>" % self.nom_type_media
return f"<BibTypesMedia {self.nom_type_media}>"


@serializable
Expand Down Expand Up @@ -223,7 +228,7 @@ class TMedias(db.Model):
bib_nom = db.relationship(BibNoms, backref="medias")

def __repr__(self):
return "<TMedias %r>" % self.titre
return f"<TMedias {self.titre}>"


@serializable
Expand All @@ -243,7 +248,7 @@ class VMTaxrefListForautocomplete(db.Model):
group3_inpn = db.Column(db.Unicode)

def __repr__(self):
return "<VMTaxrefListForautocomplete %r>" % self.search_name
return f"<VMTaxrefListForautocomplete {self.search_name} >"


@serializable
Expand All @@ -255,7 +260,7 @@ class BibTaxrefHabitats(db.Model):
desc_habitat = db.Column(db.Text)

def __repr__(self):
return "<BibTaxrefHabitats %r>" % self.nom_habitat
return f"<BibTaxrefHabitats {self.nom_habitat}>"


@serializable
Expand All @@ -267,7 +272,7 @@ class BibTaxrefRangs(db.Model):
tri_rang = db.Column(db.Integer)

def __repr__(self):
return "<BibTaxrefRangs %r>" % self.nom_rang
return f"<BibTaxrefRangs {self.nom_rang}>"


@serializable
Expand All @@ -278,7 +283,7 @@ class BibTaxrefStatus(db.Model):
nom_statut = db.Column(db.Unicode)

def __repr__(self):
return "<BibTaxrefStatus %r>" % self.nom_statut
return f"<BibTaxrefStatus {self.nom_statut}>"


@serializable
Expand All @@ -301,7 +306,7 @@ class VMTaxrefHierarchie(db.Model):
nb_tx_kd = db.Column(db.Integer)

def __repr__(self):
return "<VMTaxrefHierarchie %r>" % self.lb_nom
return f"<VMTaxrefHierarchie {self.lb_nom}>"


@serializable
Expand All @@ -323,7 +328,7 @@ class VTaxrefHierarchieBibtaxons(db.Model):
nb_tx_kd = db.Column(db.Integer)

def __repr__(self):
return "<VMTaxrefHierarchie %r>" % self.lb_nom
return f"<VMTaxrefHierarchie {self.lb_nom}>"


@serializable
Expand All @@ -336,7 +341,7 @@ class TaxrefBdcStatutType(db.Model):
thematique = db.Column(db.Unicode)
type_value = db.Column(db.Unicode)

text = db.relationship("TaxrefBdcStatutText", lazy="select")
text = db.relationship("TaxrefBdcStatutText", lazy="select", back_populates="type_statut")

@hybrid_property
def display(self):
Expand Down Expand Up @@ -372,8 +377,10 @@ class TaxrefBdcStatutText(db.Model):
doc_url = db.Column(db.Unicode)
enable = db.Column(db.Boolean)

type_statut = db.relationship("TaxrefBdcStatutType", lazy="select")
cor_text = db.relationship("TaxrefBdcStatutCorTextValues", lazy="select")
type_statut = db.relationship(TaxrefBdcStatutType, lazy="select", back_populates="text")
cor_text = db.relationship(
"TaxrefBdcStatutCorTextValues", lazy="select", back_populates="text"
)

areas = db.relationship(LAreas, secondary=bdc_statut_cor_text_area)

Expand Down Expand Up @@ -403,10 +410,10 @@ class TaxrefBdcStatutCorTextValues(db.Model):
db.Unicode, ForeignKey("taxonomie.bdc_statut_text.id_text"), nullable=False
)

text = db.relationship("TaxrefBdcStatutText", lazy="select")
value = db.relationship("TaxrefBdcStatutValues", lazy="select")
text = db.relationship(TaxrefBdcStatutText, lazy="select", back_populates="cor_text")
value = db.relationship(TaxrefBdcStatutValues, lazy="select")

taxon = db.relationship("TaxrefBdcStatutTaxon", lazy="select")
taxon = db.relationship("TaxrefBdcStatutTaxon", lazy="select", back_populates="value_text")


@serializable
Expand All @@ -423,7 +430,9 @@ class TaxrefBdcStatutTaxon(db.Model):
cd_ref = db.Column(db.Integer)
rq_statut = db.Column(db.Unicode)

value_text = db.relationship("TaxrefBdcStatutCorTextValues", lazy="select")
value_text = db.relationship(
TaxrefBdcStatutCorTextValues, lazy="select", back_populates="taxon"
)


@serializable
Expand Down
Loading