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 #16

Merged
merged 5 commits into from
Dec 7, 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
38 changes: 9 additions & 29 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ jobs:
strategy:
fail-fast: false
matrix:
debian-version: [ '10', '11' ]
sqlalchemy-version: [ '1.3', '1.4' ]
exclude:
- sqlalchemy-version: '1.3'
debian-version: '10'
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'
- 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 @@ -53,14 +50,9 @@ jobs:
--health-retries 5

steps:
- name: Add postgis_raster database extension
if: ${{ matrix.postgis-version >= 3 }}
run: |
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
env:
PGPASSWORD: geopasswd
- name: Add database extensions
run: |
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "postgis_raster";'
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "hstore";'
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "uuid-ossp";'
psql -h localhost -U geouser -d refgeo -tc 'CREATE EXTENSION "pg_trgm";'
Expand All @@ -80,24 +72,12 @@ jobs:
sudo apt update
sudo apt install -y libgdal-dev
- name: Install dependencies
if: ${{ matrix.sqlalchemy-version == '1.3' }}
run: |
python -m pip install --upgrade pip
python -m pip install \
-e .[tests] \
-e dependencies/Utils-Flask-SQLAlchemy \
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
'sqlalchemy>=1.3,<1.4' \
'flask-sqlalchemy<3'
- name: Install dependencies
if: ${{ matrix.sqlalchemy-version == '1.4' }}
run: |
python -m pip install --upgrade pip
python -m pip install \
-e .[tests] \
-e dependencies/Utils-Flask-SQLAlchemy \
-e dependencies/Utils-Flask-SQLAlchemy-Geo \
'sqlalchemy>=1.4,<2'
-e dependencies/Utils-Flask-SQLAlchemy-Geo
- name: Show database branches and dependencies
run: |
flask db status --dependencies
Expand All @@ -113,7 +93,7 @@ jobs:
run: |
pytest -v --cov --cov-report xml
- 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 @@ -2,7 +2,7 @@ alembic
flask>=2.1
flask-sqlalchemy
python-dotenv
sqlalchemy<2
sqlalchemy>=1.4,<2
utils-flask-sqlalchemy>=0.3.0
utils-flask-sqlalchemy-geo>=0.2.4
psycopg2
7 changes: 1 addition & 6 deletions src/ref_geo/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
routes = Blueprint("ref_geo", __name__)


altitude_stmt = sa.select(
[
sa.column("altitude_min"),
sa.column("altitude_max"),
]
).select_from(
altitude_stmt = sa.select(sa.column("altitude_min"), sa.column("altitude_max")).select_from(
func.ref_geo.fct_get_altitude_intersection(
func.ST_SetSRID(
func.ST_GeomFromGeoJSON(sa.bindparam("geojson")),
Expand Down
3 changes: 2 additions & 1 deletion src/ref_geo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
methodes pour ref_geo
- recupération du srid local
"""
from sqlalchemy import text


def get_local_srid(bind):
"""
permet de récupérer le srid local ( celui de ref_geo.l_areras.geom)
"""
return bind.execute("SELECT FIND_SRID('ref_geo', 'l_areas', 'geom')").scalar()
return bind.execute(text("SELECT FIND_SRID('ref_geo', 'l_areas', 'geom')")).scalar()