Closed Xeno69 closed 5 years ago
I'd just add special handling for when a string starts with [
or a is true/false, or only contains a number.
Would that handle all your use cases?
Would be optional and default disabled, I think I'd let the user enable that via config, but don't really want a seperate SQF command just for that.
Or maybe dbResultToParsedArray
or something like that? seperate command to try to parse strings into array/bool/number ?
Nope, won't handle all cases, simply because SQL data types don't match Arma ones.
Please check how extDB3 saves arrays or any other data type compared to interceptDB. As long as it is not the same it's not usable, sorry to say that.
Huh? But what I wrote doesn't have anything to do with SQL data types. It will all just be string.
How does this look?
Query: SELECT "[1,2,true,True,false,False,[1,2,3]]"
Ingame output:
[//Rows
[//Row 1
[1,2,true,true,false,false,[1,2,3]]
]
]
Handles true/false, all arrays, and everything that starts with a number.
Select "1"
-> [[1]]
Select "myvar"
-> [["myvar"]]
(fails to parse)
Select ""
-> [[""]]
cannot sensibly parse that to aynthing else.
Select "[]"
-> [[[]]]
Everything that comes from DB tries to be parsed using parseSimpleArray. If that fails it just defaults to pushing a string to the output array.
With extDB3 you have the option to return values either as string or more like Arma types.
extDB3 example:
The settings table has two columns, name and value, both are varchar in the database.
Data can look like this in the table:
extDB3 returns the name in getSettings always as string and value in some directly parsable value (with parseSimpleArray).
So db_autosave db result (after parseSimpleArray) will look like this in extDB3:
while with interceptDB the dbResultToArray looks like this:
Would be nice to have a similar feature in interceptDB (and makes using existing extDB3 databases easier and more important compatible)