Problem with malformed json using sqlite

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
kjteng
Senior Boarder
Senior Boarder
Posts: 54
Joined: 10.05.2015, 15:02

Problem with malformed json using sqlite

Post by kjteng »

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.
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.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: Problem with malformed using sqlite

Post by marsupilami »

kjteng wrote: 10.09.2022, 10:43 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.
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.
kjteng
Senior Boarder
Senior Boarder
Posts: 54
Joined: 10.05.2015, 15:02

Re: Problem with malformed json using sqlite

Post by kjteng »

Thanks for your reply.
Post Reply