Project

General

Profile

Bug #55891

Un filtre de requête utilisant une donnée calculée provoque un crash

Added by Stéphane Laget 2 months ago. Updated about 2 months ago.

Status:
Solution déployée
Priority:
Normal
Target version:
-
Start date:
28 Jul 2021
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:
No

Description

Pour tester à Strasbourg, tester avec cette url :
https://demarches-strasbourg.test.entrouvert.org/nadege/dubug-eo-candidature-a-une-offre-pour-test-crash/?refposte=E000093&libposte=offre%20emploi%20%C3%A0%20valider

le formulaire :
https://demarches-strasbourg.test.entrouvert.org/backoffice/forms/421/

un filtre de reqûete avec

{{form_objects|exclude_self|filter_by:"refposte"|filter_value:form_var_refposte|filter_by_user:form_user|count}}

Cela vient de l'utilisation d'une donnée calculée dans la requête.


Files

Associated revisions

Revision 21f7ccf6 (diff)
Added by Frédéric Péters about 2 months ago

general: add support for filtering on computed data fields (#55891)

History

#2

Updated by Frédéric Péters 2 months ago

Les données calculées sont dans une colonne json, résultat les critères ne peuvent pas s'appliquer ainsi, la trace :

Exception:
  type = '<class 'psycopg2.DataError'>', value = 'invalid input syntax for type json
LINE 1: ...atus != 'draft' AND anonymised IS NULL AND f182 = 'E000093' ...
                                                             ^
DETAIL:  Token "E000093" is invalid.
CONTEXT:  JSON data, line 1: E000093
'

Stack trace (most recent call first):
  File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1447, in count
  1445             sql_statement += ' WHERE ' + ' AND '.join(where_clauses)
  1446         conn, cur = get_connection_and_cursor()
> 1447         cur.execute(sql_statement, parameters)
  1448         count = cur.fetchone()[0]
  1449         conn.commit()

  locals:
     clause = <ERROR WHILE PRINTING VALUE>
     cls = <class 'wcs.formdef._wcs_Dubug-Eo-Candidature-A-Une-Offre-Pour-Test-Crash'>
     conn = <connection object at 0x7f9516dbad58; dsn: 'user=wcs password=xxx dbname=wcs_demarches_strasbourg_test_entrouvert_org
host=test.saas.entrouvert.org.clusters.entrouvert.org port=5432', closed: 0>
     cur = <cursor object at 0x7f9515b0d238; closed: 0>
     func_clause = None
     parameters = {'c140278378493408': 'draft', 'c140278302841912': 'E000093', 'c140278289271472': '17'}
     sql_statement = 'SELECT count(*) FROM formdata_421_candidature_a_une_offre_copie WHERE status != %(c140278378493408)s AND anonymised IS
NULL AND f182 = %(c140278302841912)s AND user_id = %(c140278289271472)s'
     where_clauses = ['status != %(c140278378493408)s', 'anonymised IS NULL', 'f182 = %(c140278302841912)s', 'user_id = %(c140278289271472)s']
#6

Updated by Frédéric Péters about 2 months ago

  • Assignee set to Frédéric Péters
#7

Updated by Frédéric Péters about 2 months ago

#8

Updated by Thomas Noël (congés → 11 octobre) about 2 months ago

  • Status changed from Solution proposée to Solution validée

Joli.

#9

Updated by Frédéric Péters about 2 months ago

  • Status changed from Solution validée to Résolu (à déployer)
commit 21f7ccf66884af8f1faf235001c21c7174fda6a4
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Tue Aug 3 08:59:01 2021 +0200

    general: add support for filtering on computed data fields (#55891)
#10

Updated by Frédéric Péters about 2 months ago

  • Status changed from Résolu (à déployer) to Solution déployée

Also available in: Atom PDF