-
-
Notifications
You must be signed in to change notification settings - Fork 53
iOS: Update from {N} 8.0 to 8.1 creates toString from null error #173
Comments
Hmm, that is interesting.
At this point the query doesn't "exist" as we are looping thru the result sets. So if you want to know which query, I would recommend you console log it out before you call the command to get the result set... Now what is very interesting about this issue is: So either:
|
Hi @NathanaelA, I'm experiencing this issue too, so here's some more info about the sql being executed:
Initially I thought that it was only occurring when creating the tables (which, weirdly, were successfully created despite the error messages), but it's actually happening on every query. Here's another example:
I can confirm that this only occurs on I ran all my tests on iOS 14.4 Hope that's helpful? Let me know if I can provide anything more useful! |
@Ed-Simmons - Can you tell me is there any null values in the data on 8.0.0 for either of those sql queries when they fail. Narrowing down why/when this occurs would be very helpful. I'll also run my test suite on 8.1.0 just to see if any of these queries break, |
@NathanaelA - Indeed there are some null values. If we take the second query I mentioned as an example, there are two nullable columns: The error is being caught in the callback of the public execute(sql: string, parameters?: string[]): Promise<any> {
return this.sqlite.all(sql, parameters).then((records: object[][]) => {
return records;
}, (error: any) => {
Database.debug(`[ERROR] ${error}`);
Database.debug(`[ERROR] {SQL} ${sql}`);
if (parameters) {
Database.debug(`[ERROR] {PARAMS} ${parameters}`);
}
return error;
});
} |
Is it possible I can get a copy of your db or even a sample that fails. (I'm willing to sign a NDA) I updated my So either:
You can try my test framework by downloading the demo in this repo, and then using the name "test" and it should run thru all the tests testing all the functionality of the sqlite framework. |
Also experiencing the same issue: Tested iOS versions: 13.7 (emulator), 14.5 (emulator), 14.7.1 (iPad mini 5th gen) "dependencies": {
"@nativescript/background-http": "^5.0.2",
"@nativescript/core": "^8.1.3",
"@nativescript/datetimepicker": "^2.1.6",
"@nativescript/geolocation": "^7.2.1",
"@nativescript/iqkeyboardmanager": "^2.0.0",
"@nativescript/theme": "^3.0.1",
"@nstudio/nativescript-pulltorefresh": "^3.0.2",
"jwt-decode": "^3.1.2",
"luxon": "^1.27.0",
"nativescript-appversion": "^1.4.4",
"nativescript-fonticon": "^2.0.2",
"nativescript-sqlite": "^2.8.4",
"nativescript-sqlite-commercial": "file:../../../Downloads/nativescript-sqlite-commercial-master.tar.gz",
"nativescript-sqlite-encrypted": "file:../../../Downloads/nativescript-sqlite-encrypted-master.tar.gz",
"nativescript-ui-sidedrawer": "^10.0.1",
"nativescript-vue": "^2.9.0",
"nativescript-vue-lifecycle-hooks": "^1.0.0",
"nativescript-vue-navigator": "^1.2.0",
"semver": "^7.3.5",
"vuelidate": "^0.7.6",
"vuex": "^3.6.2"
},
"devDependencies": {
"@nativescript/ios": "~8.1.0",
"@nativescript/types": "~8.1.0",
"@nativescript/webpack": "~5.0.0",
"nativescript-vue-template-compiler": "~2.9.0",
"sass": "^1.32.8",
"util": "^0.12.4"
}, Haven't tested the demo yet. |
Hi @NathanaelA, I tried your Demo app, and sure enough, I didn't encounter the error there - very interesting (a.k.a confusing)! I decided to try and create a simple demo app of my own this morning to try and isolate the issue, here's what I found:
Using: INSERT INTO migrations (uuid, key, created_at) VALUES (?, ?, ?) ...with values like: [ uuid(), key, ''] ...resulted in: Is this expected behaviour now? What is a ...
SELECT * FROM users WHERE uuid = "123456" ...returns an array of records (of length 1) as expected: [{
"uuid": "123456",
"email": "[email protected]",
"name": "ed",
"first_name": null,
"last_name": null,
"type": null
}] The problem starts occurring when re-loading/ re-launching the app.
SELECT * FROM migrations WHERE key = "m2020_10_09_084300_create_users_table"
Re: iOS version: I've tried this on 14.4 (simulator) & 14.5 (simulator), both with the same result. You're very welcome to this test database if it's helpful: You'll be able to see in the database that, as a result of the Hope that's helpful! :) |
Blob is a binary value (like a image). Interesting that it switched to blob, I did fix a iOS blob issue in the very latest sqlite that I discovered during my revamp/cleanup of the test framework but it was if you did Can you share a database with actual values in it, or tell me about how many records are in the migrations table, I can generate some dummy data if I have an idea. |
The database I shared yesterday (towards the bottom of the comment) has lots of values on the |
@Ed-Simmons thanks for helping me out with a sample. I tested my app with iOS 15 and unfortunately get the same error. |
@Ed-Simmons - Sorry, for some reason I thought the table was empty. I do see some values in it. I'll take a look at it. 👍 On the blob issue: |
@NathanaelA I was trying to write an empty string into the CREATE TABLE IF NOT EXISTS migrations (
uuid TEXT(36) NOT NULL,
key TEXT(255) NOT NULL,
created_at TEXT(255) NOT NULL
); INSERT INTO migrations (uuid, key, created_at) VALUES (?, ?, ?) [ uuid, key, '' ] Apologies for the delayed reply, I've been on vacation. Just double checking (as I'm sure you're already aware), have you seen this excerpt from the NativeScript blog for the @8.1.0 update?
Surely it's one of these changes that's causing the issue? SQLite databases are explicitly mentioned. |
I also get the same error on iOS runtime 8.1, and was just to post the same from the iOS 8.1 release notes ;) |
@NathanaelA I agree with @teha-at's initial observation, the error occurs in the Taking my migrations table as an example, when looping through the columns (uuid, key, and created_at) which should all be Indeed, as you correctly pointed out,
If I edit the database manually, replacing the binary blob with an empty string as intended, the error disappears:
So, that leads me to think that something is going wrong when writing empty strings to the database. I shall keep looking... |
I'll update my test suite to send a empty string to a text field to see if I can duplicate it. |
Just a FYI: I am able to duplicate it. I may have a fix, I have released v2.8.6 which has a Patch that fixes it for me... |
Yay! Looks good to me, everything's working as expected now. Thanks so much!! |
Thanks, @NathanaelA - 2.8.6 fixes this for me, also! |
I updated to 2.8.6 and the error is still there. I'll try to get deep in my code/db to look if I have another character which make this problem. |
Same issue here.
Some Text fields are just stored As BLOB. |
|
https://drive.google.com/file/d/1f3wXsgQN6pDgivSTUSyOY1k6oMHg_iY2/view?usp=sharing You can find the database on root directory called The query is on ios simulator: Ipad Pro 9.7 (iOS 15) |
Is there any update regarding the BLOB issue ? |
Sorry, I have not had a change to investigate your project. I just looked at the package.json right now to verify you were using the latest (and you are. You should have let me know you purchased a commercial license, as that would have bumped the priority dramatically. I'll be taking a look at it sometime today. |
@sb-arzan - The fix that I released does NOT fix already corrupted data in your existing SQLite files caused by the NativeScript iOS NS8.1 engine changes. All I did was work around the data corruption issue, so that data corruption shouldn't happen any more since the NativeScript team hasn't fixed the underlying issue caused by NativeScript/ios#127. The reason you are having issues is because your record with id#: 30084897 already has a corrupted "blob" record in the text value. If you are worried about already deployed applications that might have corrupted data, I could potentially update the reading routine to filter out this corrupted data. We could add code to check for null (which shouldn't happen) and replace it with '' on reading. |
@NathanaelA thanks for your assistance. We do have the commercial version. But as you also said, the corruption had happened in one of the older versions. Again, thank you for your assistance. |
@NathanaelA The issue came back as we use empty strings in some columns. Each time an empty string is inserted, we can see there is A BLOB instead and reading fails with Type null error. We are using version 2.8.6 with the latest Nativescript version. |
|
Thanks for the quick response. Currently we are using our own workaround We wrapped all I'll try to provide a repo with a simple reproduce of issue. |
I updated my App from NativeScript 8.0 to 8.1 and on iOS I wasn't able to load data from the sqlite db. The console give me
I don't no why the error appears, but in this line he occurred
https://github.com/NathanaelA/nativescript-sqlite/blob/master/src/sqlite-internal.ios.js#L713
The
NSString.stringWithUTF8String
method returns null.I have not yet been able to identify the query that triggers the error. How can I decode the statement to get the query? Should there be a check if the result null?
I use the version 2.8.4 from nativescript-sqlite.
The text was updated successfully, but these errors were encountered: