Skip to content

Commit 0e8b830

Browse files
bouttierPierre-Narcisijacquesfize
authored
SQLAlchemy 1.4 (#16)
Bump to SQLAlchemy 1.4. Part of PnX-SI/GeoNature#2751 --------- Co-authored-by: Pierre Narcisi <[email protected]> Co-authored-by: Jacques Fize <[email protected]>
1 parent d17afae commit 0e8b830

File tree

4 files changed

+13
-37
lines changed

4 files changed

+13
-37
lines changed

.github/workflows/pytest.yml

+9-29
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
debian-version: [ '10', '11' ]
21-
sqlalchemy-version: [ '1.3', '1.4' ]
22-
exclude:
23-
- sqlalchemy-version: '1.3'
24-
debian-version: '10'
20+
debian-version: [ '11', '12' ]
21+
sqlalchemy-version: [ '1.4' ]
2522
include:
26-
- debian-version: '10'
27-
python-version: '3.7'
28-
postgres-version: '11'
29-
postgis-version: '2.5'
3023
- debian-version: '11'
3124
python-version: '3.9'
3225
postgres-version: '13'
3326
postgis-version: '3.2'
27+
- debian-version: '12'
28+
python-version: '3.11'
29+
postgres-version: '15'
30+
postgis-version: '3.3'
3431

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

@@ -53,14 +50,9 @@ jobs:
5350
--health-retries 5
5451
5552
steps:
56-
- name: Add postgis_raster database extension
57-
if: ${{ matrix.postgis-version >= 3 }}
58-
run: |
59-
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
60-
env:
61-
PGPASSWORD: geopasswd
6253
- name: Add database extensions
6354
run: |
55+
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
6456
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "hstore";'
6557
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "uuid-ossp";'
6658
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "pg_trgm";'
@@ -80,24 +72,12 @@ jobs:
8072
sudo apt update
8173
sudo apt install -y libgdal-dev
8274
- name: Install dependencies
83-
if: ${{ matrix.sqlalchemy-version == '1.3' }}
84-
run: |
85-
python -m pip install --upgrade pip
86-
python -m pip install \
87-
-e .[tests] \
88-
-e dependencies/Utils-Flask-SQLAlchemy \
89-
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
90-
'sqlalchemy>=1.3,<1.4' \
91-
'flask-sqlalchemy<3'
92-
- name: Install dependencies
93-
if: ${{ matrix.sqlalchemy-version == '1.4' }}
9475
run: |
9576
python -m pip install --upgrade pip
9677
python -m pip install \
9778
-e .[tests] \
9879
-e dependencies/Utils-Flask-SQLAlchemy \
99-
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
100-
'sqlalchemy>=1.4,<2'
80+
-e dependencies/Utils-Flask-SQLAlchemy-Geo
10181
- name: Show database branches and dependencies
10282
run: |
10383
flask db status --dependencies
@@ -113,7 +93,7 @@ jobs:
11393
run: |
11494
pytest -v --cov --cov-report xml
11595
- name: Upload coverage to Codecov
116-
if: ${{ matrix.debian-version == '11' && matrix.sqlalchemy-version == '1.4' }}
96+
if: ${{ matrix.debian-version == '12' && matrix.sqlalchemy-version == '1.4' }}
11797
uses: codecov/codecov-action@v3
11898
with:
11999
flags: pytest

requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ alembic
22
flask>=2.1
33
flask-sqlalchemy
44
python-dotenv
5-
sqlalchemy<2
5+
sqlalchemy>=1.4,<2
66
utils-flask-sqlalchemy>=0.3.0
77
utils-flask-sqlalchemy-geo>=0.2.4
88
psycopg2

src/ref_geo/routes.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616
routes = Blueprint("ref_geo", __name__)
1717

1818

19-
altitude_stmt = sa.select(
20-
[
21-
sa.column("altitude_min"),
22-
sa.column("altitude_max"),
23-
]
24-
).select_from(
19+
altitude_stmt = sa.select(sa.column("altitude_min"), sa.column("altitude_max")).select_from(
2520
func.ref_geo.fct_get_altitude_intersection(
2621
func.ST_SetSRID(
2722
func.ST_GeomFromGeoJSON(sa.bindparam("geojson")),

src/ref_geo/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
methodes pour ref_geo
33
- recupération du srid local
44
"""
5+
from sqlalchemy import text
56

67

78
def get_local_srid(bind):
89
"""
910
permet de récupérer le srid local ( celui de ref_geo.l_areras.geom)
1011
"""
11-
return bind.execute("SELECT FIND_SRID('ref_geo', 'l_areas', 'geom')").scalar()
12+
return bind.execute(text("SELECT FIND_SRID('ref_geo', 'l_areas', 'geom')")).scalar()

0 commit comments

Comments
 (0)