find() with uuid

Questions, tips and tricks and techniques for scripting in Servoy

find() with uuid

Postby japink.m » Sat Nov 22, 2014 4:35 pm

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.
japink.m
 
Posts: 20
Joined: Fri Jun 14, 2013 9:13 pm

Re: find() with uuid

Postby mboegem » Sat Nov 22, 2014 6:10 pm

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1384
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: find() with uuid

Postby japink.m » Sat Nov 22, 2014 10:43 pm

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.
japink.m
 
Posts: 20
Joined: Fri Jun 14, 2013 9:13 pm

Re: find() with uuid

Postby swingman » Sun Nov 23, 2014 4:32 pm

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
}
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1173
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: find() with uuid

Postby japink.m » Thu Nov 27, 2014 9:14 pm

I changed the postgresql datatype from uuid to varchar. Problem solved. Seems a Servoy-bug to me?
japink.m
 
Posts: 20
Joined: Fri Jun 14, 2013 9:13 pm

Re: find() with uuid

Postby jcompagner » Thu Dec 04, 2014 10:30 am

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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7978
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: Google [Bot] and 4 guests