andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.75k stars 521 forks source link

Issue getting results when querying a db field where NULL exist #526

Open elmcapp opened 2 years ago

elmcapp commented 2 years ago

I am trying to query the database and there are some cases where a value could be null. The issue is that I don't get a results back when trying to query where a value could be null

I need to be able to keep the format using value array because the values will be coming from variable which will be dynamic. I just used static values to provide example of issue

tx.executeSql(
    'SELECT * FROM MidiMap WHERE profileId= ? AND midiType= ? AND other= ?;',
    [
      1234567890,
      'noteOff',
      null // <-----not working
    ],

tx.executeSql(
    'SELECT * FROM MidiMap WHERE profileId= ? AND midiType= ? AND other= ?;',
    [
        1234567890,
        'noteOff',
        undefined // <----- not working
    ],

tx.executeSql(
    'SELECT * FROM MidiMap WHERE profileId= ? AND midiType= ? AND other= ?;',
    [
        1234567890,
        'noteOff',
        NULL  // <----- React do not accept this as a value
    ],

tx.executeSql(
    'SELECT * FROM MidiMap WHERE profileId= ? AND midiType= ? AND other= ?;',
    [
        1234567890,
        'noteOff',
        "NULL"  // <----- This SQL Library dos not understand this value here
    ],

// Below Works perfectly
tx.executeSql(
    'SELECT * FROM MidiMap WHERE profileId= 1234567890 AND midiType= "noteOff" AND other= NULL;',
[]