-2

How can I do a delete in flutter using NOT IN() ? I have tried few ways but the app is always crashing :

  • either it's closing the app with zero error or message :

**

await db.rawDelete('DELETE FROM ' +
      dao.tableName +
      ' WHERE ' +
      dao.columnUuid +
      ' NOT IN (' +
      params.join(',') +
      ')');

**

  • or it gives me

    *Invalid argument ['2e73c330-1312-42fa-ad3b-d762f96b5ec7', '1ba3e7e3-2d57-4916-9ea5-2624432cf60c'] with type List. Only num, String and Uint8List are supported. See https://github.com/tekartik/sqflite_common/blob/master/sqflite_common/doc/supported_types.md for details This will throw an exception in the future. For now it is displayed once per type.

      await db.rawDelete(
                'DELETE FROM ' +
                    dao.tableName +
                    ' WHERE ' +
                    dao.columnUuid +
                    ' NOT IN (${('?' * (params.length)).split('').join(', ')})',
                [params]);*
    

    Params is a List of Strings : ['2e73c330-1312-42fa-ad3b-d762f96b5ec7', '1ba3e7e3-2d57-4916-9ea5-2624432cf60c']

I know about the SQL injection issue. Any help would be welcome.

Jérôme
  • 403
  • 1
  • 3
  • 13

1 Answers1

0

params is already a list but in your code you are using [params] (which is a list of list, hence the error displayed) instead of just params

alextk
  • 5,713
  • 21
  • 34