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

SQLAlchemy 1.4 #54

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
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
40 changes: 11 additions & 29 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,17 @@ jobs:
strategy:
fail-fast: false
matrix:
debian-version: [ "10", "11" ]
sqlalchemy-version: [ "1.3", "1.4" ]
debian-version: [ "11", "12" ]
sqlalchemy-version: [ "1.4" ]
include:
- debian-version: "10"
python-version: "3.7"
postgres-version: 11
postgis-version: 2.5
- debian-version: "11"
python-version: "3.9"
postgres-version: 13
postgis-version: 3.2
- sqlalchemy-version: '1.3'
sqlalchemy-lt-version: '1.4'
flask-sqlalchemy-version: '2'
flask-sqlalchemy-lt-version: '3'
- sqlalchemy-version: '1.4'
sqlalchemy-lt-version: '2'
flask-sqlalchemy-version: '3'
flask-sqlalchemy-lt-version: '4'
exclude:
- debian-version: "10"
sqlalchemy-version: "1.4"
postgres-version: "13"
postgis-version: "3.2"
- debian-version: "12"
python-version: "3.11"
postgres-version: "15"
postgis-version: "3.3"

name: Debian ${{ matrix.debian-version }} - SQLAlchemy ${{ matrix.sqlalchemy-version }}

Expand All @@ -59,14 +48,9 @@ jobs:
--health-retries 5

steps:
- name: Add postgis_raster database extension
if: ${{ matrix.postgis-version >= 3 }}
run: |
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "postgis_raster";'
env:
PGPASSWORD: postgres
- name: Add database extensions
run: |
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "postgis_raster";'
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "uuid-ossp";'
psql -h localhost -U postgres -d postgres -tc 'CREATE EXTENSION "pg_trgm";'
env:
Expand All @@ -86,9 +70,7 @@ jobs:
-e .[tests] \
-e file:dependencies/Utils-Flask-SQLAlchemy#egg=utils-flask-sqlalchemy \
-e file:dependencies/TaxHub#egg=taxhub \
-e file:dependencies/UsersHub-authentification-module#egg=pypnusershub \
"sqlalchemy>=${{ matrix.sqlalchemy-version }},<${{ matrix.sqlalchemy-lt-version }}" \
"flask-sqlalchemy>=${{ matrix.flask-sqlalchemy-version }},<${{ matrix.flask-sqlalchemy-lt-version }}"
-e file:dependencies/UsersHub-authentification-module#egg=pypnusershub
- name: Install database
run: |
flask db upgrade ref_geo@head -x local-srid=2154
Expand All @@ -104,7 +86,7 @@ jobs:
env:
NOMENCLATURE_SETTINGS: test_settings.py
- name: Upload coverage to Codecov
if: ${{ matrix.debian-version == '11' && matrix.sqlalchemy-version == '1.4' }}
if: ${{ matrix.debian-version == '12' && matrix.sqlalchemy-version == '1.4' }}
uses: codecov/codecov-action@v3
with:
flags: pytest
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ psycopg2
flask-marshmallow
marshmallow-sqlalchemy
shapely<2
sqlalchemy>=1.3,<2
sqlalchemy>=1.4,<2

utils-flask-sqlalchemy>=0.3.0
taxhub>=1.10.0
Expand Down
18 changes: 10 additions & 8 deletions src/pypnnomenclature/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
id_type = db.Column(
db.Integer, ForeignKey("ref_nomenclatures.bib_nomenclatures_types.id_type")
)
nomenclature_type = relationship("BibNomenclaturesTypes", backref="nomenclatures")
nomenclature_type = relationship(
"BibNomenclaturesTypes",
backref="nomenclatures",
)
cd_nomenclature = db.Column(db.Unicode)
mnemonique = db.Column(db.Unicode)
label_default = db.Column(db.Unicode)
Expand All @@ -73,14 +76,12 @@
@staticmethod
def get_default_nomenclature(mnemonique, id_organism=0):
q = select(
[
func.ref_nomenclatures.get_default_nomenclature_value(
mnemonique, id_organism
).label("default")
]
func.ref_nomenclatures.get_default_nomenclature_value(mnemonique, id_organism).label(
"default"
)
)
result = db.session.execute(q)
return result.fetchone()["default"]
return result.fetchone().default

Check warning on line 84 in src/pypnnomenclature/models.py

View check run for this annotation

Codecov / codecov/patch

src/pypnnomenclature/models.py#L84

Added line #L84 was not covered by tests


class TNomenclatureTaxonomy(TNomenclatures):
Expand Down Expand Up @@ -127,7 +128,7 @@
]
)
result = db.session.execute(q)
return result.fetchone()["default"]
return result.fetchone().default

Check warning on line 131 in src/pypnnomenclature/models.py

View check run for this annotation

Codecov / codecov/patch

src/pypnnomenclature/models.py#L131

Added line #L131 was not covered by tests


class BibNomenclaturesTypeTaxo(BibNomenclaturesTypes):
Expand All @@ -140,6 +141,7 @@
primaryjoin="and_(TNomenclatureTaxonomy.id_type == BibNomenclaturesTypes.id_type, TNomenclatureTaxonomy.active == True)",
lazy="joined",
order_by="TNomenclatureTaxonomy.hierarchy",
viewonly=True,
)


Expand Down
Loading