SQLite numeric column returning string

Hello, i’m trying to insert and recover the data from sqlite but a numeric column is returning string when inserted null.
Create table:

db.transaction(tx => {
  tx.executeSql(
    'create table if not exists items (id integer primary key not null, latitude numeric, longitude numeric);'
  );
});

Insert example:

db.transaction(
  tx => {
    tx.executeSql('insert into items (id, latitude, longitude) values (?, ?, ?)', [1, null, null]);
  }
);

Select example:

db.transaction(tx => {
  tx.executeSql(
    'select * from items',
    [],
    (_, { rows: { _array } }) => console.log(_array))
  );
});

My return (Latitude and longitude are string):

{id: 1, latitude: "null", longitude: "null"}

Expected return:

{id: 1, latitude: null, longitude: null}

Hey! Can you confirm that the type is indeed 'string' with typeof (to make sure it’s not just a bad stringification by console.log(...)

It would also be helpful if you could provide a Snack with the exact code you’re running!

Follows the SNACK
I forgot to explain, it occurs only on Android. IOS works well.

Another question:

  1. If i pass the values by params like tx.executeSql('insert into items (latitude, longitude) values (?, ?)', [null, null]); the select returns a string.

  2. If i pass the values by params like tx.executeSql('insert into items (latitude, longitude) values (null, null)'); the select returns really a boolean.

Tracking here: https://github.com/expo/expo/issues/804.

1 Like

Tested in https://github.com/expo/test-suite/commit/3d7093a8c234d525b39c24c2aa52e29901404cdb, which passes already on iOS. Passes on Android after https://github.com/expo/expo/commit/eb4f4343557b63795fa92b62a7ea42407c0cf82e. Most likely will be released in SDK 24!

1 Like