SDK 33 SQLite date bug

This is working in SDK 32.0.0, both in debug and published in iOS and Android
MAC OS 10.14.5
Running in iOS simulator iPhone 6, 10.3
***update - same problem running simulator using iPhone 6S 12.2
*** updated to expo-cli@2.21.2 and now it doesn’t work at all!
Getting " Cound not find proper type in SQLite module" TYPO IS NOT MINE

When I run in debug, everything works fine. Running without debug, SQLite is not writing the date object correctly.

dependencies:

“eslint”: “^5.9.0”,
“exp”: “^57.2.1”,
“expo”: “^33.0.0”,
“expo-asset”: “^5.0.1”,
“expo-av”: “~5.0.2”,
“expo-file-system”: “~5.0.1”,
“expo-localization”: “~5.0.1”,
“expo-permissions”: “~5.0.1”,
“expo-sqlite”: “~5.0.1”,
“expo-web-browser”: “~5.0.2”,
“moment”: “^2.22.2”,
“moment-timezone”: “^0.5.23”,
“react”: “16.8.3”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz”,
“react-native-device-info”: “^0.24.3”,
“react-native-modal-datetime-picker”: “^6.0.0”,
“react-navigation”: “^3.11.0”

code:
var theDB = this.state.database;
var start = 0;
var end = 0;
const personID = 0;
const scheduleID = 0;
const responseID = 0;
const upDT = new Date();
console.log('creating drill history, upDT: ',upDT);
if (drillStatus === “STARTED”) {
start = new Date();
console.log('creating drill history, start: ',start);
end = 0;
try {
theDB.transaction(
tx => {
tx.executeSql(
"INSERT INTO DrillsHistory ( " +
“drillStatus, personID,start, end, " +
“recordingID, scheduleID, responseID, lastUPDT )” +
" VALUES (?,?,?,?,?,?,?,?)”,
[
drillStatus, personID, start, end, recordingID, scheduleID, responseID, upDT
],
(_, insertedInfo) => {
this.setState({ startDrillDT: start });
this.setState({ drillRecord: insertedInfo });
},
(etx, error) => {
console.log("insert error record: ", this.state.drill);
console.log(etx);
console.log(error);
console.log( “rec info:”, drillStatus, personID,start, end,recordingID,scheduleID,responseID,upDT);
},
);
}
);
} catch (error) {
console.log("error writing the DrillsHistory record: ", error);
}

The console log shows the upDT as legit date:
creating drill history, upDT: 2019-07-02T19:33:10.248Z
creating drill history, start: 2019-07-02T19:33:10.253Z
creating drill history, upDT: 2019-07-02T19:33:23.395Z
updating drill history, doneDT: 2019-07-02T19:33:23.396

When I write a date to the database, it writes an empty object in the date time fields.
(hope you can see the screen grab):

Has anyone else run into this?
Thank you!

*****update: it seems to do the same thing when running on my iPhone - I can’t access my SQLite db so can’t be sure, but the behavior is the same.

Android- I have spent hours trying to figure out how to view the emulator db in Android with no luck. I did publish to a staging channel and used the QR code and got an error regarding the upDT, but the whole thing seems borked on my Android device

I have exactly the same problem. There is already an issue here: https://github.com/expo/expo-cli/issues/809 , but I am not sure, that anyone is going to investigate it :frowning: no response…

Ok, I have found a solution.

The problem is, that I pass Date object param to tx.executeSql instead of STRING. There was propably some automatic conversion. In console log it was “OK”, because console converted it automatically too.

If I manually convert Date to String throught .toISOString(), than it works correctly.

THANK YOU!!! I will give this a try.

****update - this worked for me- thank you, @xsychr03 !

1 Like