Page 1 of 1

find() with uuid

PostPosted: Sat Nov 22, 2014 4:35 pm
by japink.m
In Servoy 7.4 I can do the find() on a uuid field. When i try in webclient I get the error:
ERROR: operator does not exist: uuid = character varying. You might need to add explicit type casts.

I couldn't find a method to set String.toUUID(), only the other way around.

It's a dynamically find method: Depending on user selection it performs a search on multiple fields. Fields and search values are stored in an object.
With JSDOC type I have declared the attributes as UUID but still it seen as String.
* {{user_uuid:UUID, solution_uuid:UUID, project_uuid:UUID, group_uuid:UUID}} oSELECTION
var sField
if (foundset.find()){
for (sField in oSELECTION){
foundset[sField]=oSELECTION[sField];
foundset.user_uuid
}
foundset.search();
}

Can anyone please tell me how to handle this?
Thanks in advance.

Re: find() with uuid

PostPosted: Sat Nov 22, 2014 6:10 pm
by mboegem
japink.m wrote:With JSDOC type I have declared the attributes as UUID but still it seen as String.

That's correct, it's documentation not code.
Adding JSDoc will help the parser nothing more.

japink.m wrote:I couldn't find a method to set String.toUUID(), only the other way around.

you can use: application.getUUID(<YourUUIDString>)

Hope that last bit helps you to solve the problem.

Re: find() with uuid

PostPosted: Sat Nov 22, 2014 10:43 pm
by japink.m
mboegem wrote:
japink.m wrote:With JSDOC type I have declared the attributes as UUID but still it seen as String.

That's correct, it's documentation not code.
Adding JSDoc will help the parser nothing more.

japink.m wrote:I couldn't find a method to set String.toUUID(), only the other way around.

you can use: application.getUUID(<YourUUIDString>)

Hope that last bit helps you to solve the problem.


Thanks for your reaction .

No it keeps complaining. I changed the search criteria to:
foundset[sField]=application.getUUID(oSELECTION[sField]);
smartclient is still working. Webclient won't work. I don't understand why web is behaving here different from smart. I flagged the uuid columns so Servoy should be aware?
Are there any examples with find and UUID? Cannot find any.

Re: find() with uuid

PostPosted: Sun Nov 23, 2014 4:32 pm
by swingman
Hi, you can try the following to see if it helps -- it works in smart-client.
You need to change the query to match your table and field names.

Code: Select all
var query = "SELECT uid FROM some_table WHERE uid LIKE ? ORDER BY something";
var args = [];
//search_for is a uuid.
args.push(search_for + "%")
if(controller.loadRecords(query,args)) {
//you may have found something
}

Re: find() with uuid

PostPosted: Thu Nov 27, 2014 9:14 pm
by japink.m
I changed the postgresql datatype from uuid to varchar. Problem solved. Seems a Servoy-bug to me?

Re: find() with uuid

PostPosted: Thu Dec 04, 2014 10:30 am
by jcompagner
you can make a case so that we can look at it.
i guess when you have a UUID field in the db. we really need to use a special setXxxx on the sql statements or something