react-native-sqlite-storage icon indicating copy to clipboard operation
react-native-sqlite-storage copied to clipboard

Issue getting results when querying a db field where NULL exist

Open elmcapp opened this issue 3 years ago • 0 comments

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;',
[]

elmcapp avatar Jul 27 '22 18:07 elmcapp