I have a sqlite table with ID and DATA (Text, to store json data) fields as follows:
ID DATA
1 [1,2,3]
2 ["1","2","3"]
3 [1,2,3, [4,5,6]]
4 [1,2,3,{"AA":4, "BB":5, "CC":6}]
5 [1,2,3
6 [1]
7 {"AA":1}
When I query (using TZQuery) the table with SELECT ID, DATA, json(DATA) FROM TEST
it will raise exception (because record 5 is an invalid JSON) and the the program starts to behalve abnormally because there is memory leak.
I tried the same using TSQlite component, it returns records 1 to 4 and then raise exception. However there is no memory leak.
Is this a bug in the zeoslib component? How to solve this (other then using WHERE clause to filter out the invalid records)?
Attached test.zip (test1 project is using zeoslib and test2 is using TsqliteQuery)
I am using Lazarus 2.2.2 with zeoslib-code-0-r7860-trunk.
Problem with malformed json using sqlite
Problem with malformed json using sqlite
You do not have the required permissions to view the files attached to this post.
Last edited by kjteng on 11.09.2022, 01:34, edited 1 time in total.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: Problem with malformed using sqlite
The memory leak is a bug and needs to be fixed.
Raising the exception is normal behaviour. You need to filter the data if you don't want an exception. If an exception is generated then it is undefined wether you will see any data at all or no data. Also it is not defined which data you will see.
Re: Problem with malformed json using sqlite
Thanks for your reply.