Skip to content

Commit ac84d02

Browse files
bouttierPierre-Narcisijacquesfize
committed
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 4770bde commit ac84d02

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

.github/workflows/pytest.yml

+7-24
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
include:
2323
- debian-version: "11"
2424
python-version: "3.9"
25-
postgres-version: "11"
26-
postgis-version: "2.5"
27-
- debian-version: "12"
28-
python-version: "3.11"
2925
postgres-version: "13"
3026
postgis-version: "3.2"
27+
- debian-version: "12"
28+
python-version: "3.11"
29+
postgres-version: "15"
30+
postgis-version: "3.3"
3131

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

@@ -50,14 +50,9 @@ jobs:
5050
--health-retries 5
5151
5252
steps:
53-
- name: Add postgis_raster database extension
54-
if: ${{ matrix.postgis-version >= 3 }}
55-
run: |
56-
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
57-
env:
58-
PGPASSWORD: geopasswd
5953
- name: Add database extensions
6054
run: |
55+
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
6156
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "hstore";'
6257
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "uuid-ossp";'
6358
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "pg_trgm";'
@@ -77,24 +72,12 @@ jobs:
7772
sudo apt update
7873
sudo apt install -y libgdal-dev
7974
- name: Install dependencies
80-
if: ${{ matrix.sqlalchemy-version == '1.3' }}
81-
run: |
82-
python -m pip install --upgrade pip
83-
python -m pip install \
84-
-e .[tests] \
85-
-e dependencies/Utils-Flask-SQLAlchemy \
86-
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
87-
'sqlalchemy>=1.3,<1.4' \
88-
'flask-sqlalchemy<3'
89-
- name: Install dependencies
90-
if: ${{ matrix.sqlalchemy-version == '1.4' }}
9175
run: |
9276
python -m pip install --upgrade pip
9377
python -m pip install \
9478
-e .[tests] \
9579
-e dependencies/Utils-Flask-SQLAlchemy \
96-
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
97-
'sqlalchemy>=1.4,<2'
80+
-e dependencies/Utils-Flask-SQLAlchemy-Geo
9881
- name: Show database branches and dependencies
9982
run: |
10083
flask db status --dependencies
@@ -110,7 +93,7 @@ jobs:
11093
run: |
11194
pytest -v --cov --cov-report xml
11295
- name: Upload coverage to Codecov
113-
if: ${{ matrix.debian-version == '11' && matrix.sqlalchemy-version == '1.4' }}
96+
if: ${{ matrix.debian-version == '12' && matrix.sqlalchemy-version == '1.4' }}
11497
uses: codecov/codecov-action@v3
11598
with:
11699
flags: pytest

requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ flask>=2.1
33
flask-sqlalchemy
44
flask-marshmallow
55
python-dotenv
6-
sqlalchemy<2
6+
sqlalchemy>=1.4,<2
77
utils-flask-sqlalchemy>=0.3.0
88
utils-flask-sqlalchemy-geo>=0.2.8
99
psycopg2

src/ref_geo/routes.py

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

1919

20-
altitude_stmt = sa.select(
21-
[
22-
sa.column("altitude_min"),
23-
sa.column("altitude_max"),
24-
]
25-
).select_from(
20+
altitude_stmt = sa.select(sa.column("altitude_min"), sa.column("altitude_max")).select_from(
2621
func.ref_geo.fct_get_altitude_intersection(
2722
func.ST_SetSRID(
2823
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)