PnX-SI / gn_mobile_occtax

Application mobile pour la saisie dans le module Occtax de GeoNature
GNU General Public License v3.0
13 stars 5 forks source link

Saisie d'un nom vernaculaire contenant un apostrophe #230

Closed cen-cgeier closed 1 month ago

cen-cgeier commented 1 year ago

Version de l'application

Version d'Occtax-mobile affectée par le bug : 2.6.1 Version de GeoNature utilisée : 2.12.3

Terminal et Version Android

Marque et modèle du terminal : Samsung galaxy note10+ Version d'Android : 12

Description du bug et comportement attendu

A la saisie d'un apostrophe dans la barre de recherche du choix d'un taxon :

Le comportement attendu serait de retourner des taxons contenant des apostrophes dans leur nom.

Comment reproduire

Saisir un nouveau relevé et rechercher un taxon par le biais de son nom vernaculaire contenant un apostrophe dans son nom. exemple : Capnode de l'Oseille, Ophrys d'avril, Frelon d'Europe, ... Plus simplement, saisir l' et le bug se produit.

Logs

16:04:37.742 DEBUG: [fr.geonature.commons.data.helper.SQLiteSelectQueryBuilder] sql:
  SELECT taxa."_id" AS taxa__id, taxa."name" AS taxa_name, taxa."kingdom" AS taxa_kingdom, taxa."group" AS taxa_group, taxa."name_common" AS taxa_name_common, taxa."description" AS taxa_description, taxa."rank" AS taxa_rank
  FROM taxa taxa
  WHERE ((taxa_name GLOB ? OR taxa_name_common GLOB ? OR taxa_description GLOB ? OR taxa_rank LIKE ?))
  ORDER BY (CASE WHEN (taxa_name = 'frelon d'' OR taxa_name_common = 'frelon d'') THEN 1 WHEN (taxa_name LIKE '%frelon d'%' OR taxa_name_common LIKE '%frelon d'%') THEN 2 WHEN (taxa_name GLOB '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*' OR taxa_name_common GLOB '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*') THEN 3 ELSE 4 END)
  args: ['*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*', '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*', '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*', '%frelon d'%']
16:04:37.744 ERROR: [fr.geonature.occtax.MainApplication$TinylogUncaughtExceptionHandler] java.lang.RuntimeException: An error occurred while executing doInBackground()
    at androidx.loader.content.ModernAsyncTask$3.done(ModernAsyncTask.java:164)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)
  Caused by: android.database.sqlite.SQLiteException: near "frelon": syntax error (code 1 SQLITE_ERROR[1]): , while compiling: SELECT taxa."_id" AS taxa__id, taxa."name" AS taxa_name, taxa."kingdom" AS taxa_kingdom, taxa."group" AS taxa_group, taxa."name_common" AS taxa_name_common, taxa."description" AS taxa_description, taxa."rank" AS taxa_rank
  FROM taxa taxa
  WHERE ((taxa_name GLOB ? OR taxa_name_common GLOB ? OR taxa_description GLOB ? OR taxa_rank LIKE ?))
  ORDER BY (CASE WHEN (taxa_name = 'frelon d'' OR taxa_name_common = 'frelon d'') THEN 1 WHEN (taxa_name LIKE '%frelon d'%' OR taxa_name_common LIKE '%frelon d'%') THEN 2 WHEN (taxa_name GLOB '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*' OR taxa_name_common GLOB '*[fF][rR][eéèëêẽEÉÈËÊẼ][lL][oóòöôõõOÓÒÖÔÕ][nñNÑ] [dD]'*') THEN 3 ELSE 4 END)
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1478)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:916)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:63)
    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2088)
    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2063)
    at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.query(FrameworkSQLiteDatabase.kt:156)
    at androidx.room.RoomDatabase.query(RoomDatabase.kt:490)
    at androidx.room.RoomDatabase.query$default(RoomDatabase.kt:484)
    at androidx.room.RoomDatabase.query(Unknown Source:7)
    at fr.geonature.commons.data.dao.TaxonDao_Impl.query(TaxonDao_Impl.java:482)
    at fr.geonature.commons.data.dao.BaseDao$QB.cursor(BaseDao.kt:110)
    at fr.geonature.commons.data.MainContentProvider.taxaQuery(MainContentProvider.kt:515)
    at fr.geonature.commons.data.MainContentProvider.query(MainContentProvider.kt:238)
    at android.content.ContentProvider.query(ContentProvider.java:1520)
    at android.content.ContentProvider.query(ContentProvider.java:1616)
    at android.content.ContentProvider$Transport.query(ContentProvider.java:286)
    at android.content.ContentResolver.query(ContentResolver.java:1226)
    at android.content.ContentResolver.query(ContentResolver.java:1158)
    at androidx.core.content.ContentResolverCompat$Api16Impl.query(ContentResolverCompat.java:119)
    at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:87)
    at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63)
    at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:41)
    at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
    at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 3 more
camillemonchicourt commented 1 year ago

OK bien vu. En effet on n'avait pas repéré ça, mais la recherche doit ne pas aimer les apostrophes et planter sur celles-ci.

cen-cgeier commented 1 year ago

Oui en effet et ça engendre un plantage global du relevé nouveau ou édité. Il faudrait doubler l'apostrophe lorsqu'il est saisie.

camillemonchicourt commented 1 month ago

Corrigé dans la 2.7.0.