Open agufagit opened 8 months ago
current SmartUnmarshal only handles array return results, doesn't handle other return types such as create only user which returns an object.
create only user
the new SmartUnmarshalRaw1 only handles raw query, and only handles single return result: [map[result:true status:OK time:4.219606ms]]
This is required because of custom functions DEFINE FUNCTION fn::xxx and BEGIN;...COMMIT; block doesn't return arrays, and only returns single result.
DEFINE FUNCTION fn::xxx
BEGIN;...COMMIT;
it also handles THROW statement errors BEGIN; THROW 'blocked'; COMMIT; : [map[result:An error occurred: blocked status:ERR time:4.219606ms]]
THROW
BEGIN; THROW 'blocked'; COMMIT;
this function should cover 99% of people's needs
tested against surrealdb v1.0.0
Thanks for the PR @agufagit, I was working on my project and I faced similar problems with current driver. It can be good to add something like this as a helper function.
@phughk , @timpratim what do you think?
current SmartUnmarshal only handles array return results, doesn't handle other return types such as
create only user
which returns an object.the new SmartUnmarshalRaw1 only handles raw query, and only handles single return result: [map[result:true status:OK time:4.219606ms]]
This is required because of custom functions
DEFINE FUNCTION fn::xxx
andBEGIN;...COMMIT;
block doesn't return arrays, and only returns single result.it also handles
THROW
statement errorsBEGIN; THROW 'blocked'; COMMIT;
: [map[result:An error occurred: blocked status:ERR time:4.219606ms]]this function should cover 99% of people's needs
tested against surrealdb v1.0.0