Replace deprecated SQLAlchemy Table.count() by sqlfunc.count().
[philipp/winterrodeln/wrpylib.git] / wrpylib / wrmwcache.py
index adbb1cda25c1acec14acfd00a40e67b0941e0f29..95e0e96805f3d0ba8a5af4ff1e97c23890b372c1 100644 (file)
@@ -50,7 +50,7 @@ def update_wrsledruncache(connection):
             sledrun.page_id = sledrun_page.page_id
             sledrun.page_title = sledrun_page.page_title
             sledrun.name_url = wrvalidators.sledrun_page_title_to_pretty_url(sledrun_page.page_title)
-            sledrun.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==sledrun_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x').count()).fetchone()[0] > 0
+            sledrun.under_construction = connection.execute(select([sqlfunc.count()], (categorylinks.c.cl_from==sledrun_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x')).fetchone()[0] > 0
             connection.execute(wrsledruncache.insert(sledrun.__dict__))
         except ValueError as e:
             transaction.rollback()
@@ -93,7 +93,7 @@ def update_wrinncache(connection):
             inn = wrmwmarkup.inn_from_gasthausbox(gasthausbox, Inn())
             inn.page_id = inn_page.page_id
             inn.page_title = inn_page.page_title
-            inn.under_construction = connection.execute(select([categorylinks], (categorylinks.c.cl_from==inn_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x').count()).fetchone()[0] > 0 # It would be better to do this in the query above
+            inn.under_construction = connection.execute(select([sqlfunc.count()], (categorylinks.c.cl_from==inn_page.page_id) & (categorylinks.c.cl_to == 'In_Arbeit')).alias('x')).fetchone()[0] > 0 # It would be better to do this in the query above
             connection.execute(wrinncache.insert(inn.__dict__))
         except ValueError as e:
             transaction.rollback()