IsValid("uuid", value) fails for uuid types in PostgreSQL

Description

Using the PostgreSQL driver (version 9.4.1212), UUID values that are converted to a string, are not valid when using IsValid("uuid", value), but they do validate as "guid" types. Looking at the format of the string, it's in a guid format and not a uuid format.

(Note, PostgreSQL is returning uuid types as java classes), so converting to a string is sometimes necessary, thought the format is obviously a guid and not a uuid.

Attachments

2
  • 26 Jul 2018, 09:55 pm
  • 20 Jul 2018, 08:04 pm

Activity

Show:

JP 17 August 2018 at 20:20

I agree... any changes could break a lot of things.

It's clear that the 8-4-4-4-12 format is for GUID. I think the iso specification for UUIDs is unclear on the string representation, so technically, a UUID could be represented in the GUID format. As you mentioned, both types are stored the same way in memory.

Isn't it PostgreSQL that has defined the string format of their UUID data type?

Igal Sapir 17 August 2018 at 18:43

createGUID() produces the format in groups of 8-4-4-4-12

createUUID() produces the format in groups of 8-4-4-16

The example that you posted above is in the format of 8-4-4-4-12 so it returns true of is-GUID and false for is-UUID.

The information stored in memory is of the same length of 128 bit, and the only difference is the dash symbol that splits the 16 characters into 4 and 12 in the createUUID() function.

I am having trouble finding more information about the 8-4-4-16 format. Wikipedia shows the 8-4-4-4-12 format. Even on MySQL the format is in 8-4-4-4-12.

TBH I am not sure where 8-4-4-16 came from. The problem is that if we make them interchangeable, then we have two different string lengths: 36 characters, and 35 characters, and then if you will try to insert a 36-char long string into a 35-char database field you will get an error of data truncation.

Any change can break backwards compatibility. Perhaps we should make a more public conversation about this in dev.lucee.org and decide what to do, if anything.

JP 30 July 2018 at 16:22

Yea, I think this is an issue with the toString() method of a UUID type in the JDBC driver. They are formatting a UUID like a GUID. Would you concur?

Igal Sapir 27 July 2018 at 18:20

I see what you mean now.

But what happens if you try to insert a GUID into a database that expects a UUID, or the other way around? For example:

if (isValid("uuid", id){ queryExecute(...) // insert into a database system that expects a GUID }

If that fails then it creates a new problem.

Also, keep in mind that the current behavior is compatible with ACF.

JP 26 July 2018 at 21:55
Edited

I posted an example in the screenshot above, but here's another one:

var companyID = '4ed8b7fb-b707-48a8-a0ee-ab8c7cd6474d'; writeOutput("<p>UUID: #isValid("uuid", companyID)#, GUID: #isValid("guid", companyID)#</p>");

Details

Assignee

Reporter

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Priority

Created 20 July 2018 at 20:06
Updated 9 July 2020 at 11:00