@@ -70,10 +70,10 @@ public abstract class GraphQLSupportedTypesTestBase : SqlTestBase
7070 [ DataRow ( BYTEARRAY_TYPE , 2 ) ]
7171 [ DataRow ( BYTEARRAY_TYPE , 3 ) ]
7272 [ DataRow ( BYTEARRAY_TYPE , 4 ) ]
73- [ DataRow ( GUID_TYPE , 1 ) ]
74- [ DataRow ( GUID_TYPE , 2 ) ]
75- [ DataRow ( GUID_TYPE , 3 ) ]
76- [ DataRow ( GUID_TYPE , 4 ) ]
73+ [ DataRow ( UUID_TYPE , 1 ) ]
74+ [ DataRow ( UUID_TYPE , 2 ) ]
75+ [ DataRow ( UUID_TYPE , 3 ) ]
76+ [ DataRow ( UUID_TYPE , 4 ) ]
7777 public async Task QueryTypeColumn ( string type , int id )
7878 {
7979 if ( ! IsSupportedType ( type ) )
@@ -140,6 +140,8 @@ public async Task QueryTypeColumn(string type, int id)
140140 [ DataRow ( DECIMAL_TYPE , "eq" , "-9.292929" , "-9.292929" , "=" ) ]
141141 [ DataRow ( BOOLEAN_TYPE , "neq" , "\' false\' " , "false" , "!=" ) ]
142142 [ DataRow ( BOOLEAN_TYPE , "eq" , "\' false\' " , "false" , "=" ) ]
143+ [ DataRow ( UUID_TYPE , "eq" , "'D1D021A8-47B4-4AE4-B718-98E89C41A161'" , "\" D1D021A8-47B4-4AE4-B718-98E89C41A161\" " , "=" ) ]
144+ [ DataRow ( UUID_TYPE , "neq" , "'D1D021A8-47B4-4AE4-B718-98E89C41A161'" , "\" D1D021A8-47B4-4AE4-B718-98E89C41A161\" " , "!=" ) ]
143145 public async Task QueryTypeColumnFilterAndOrderBy ( string type , string filterOperator , string sqlValue , string gqlValue , string queryOperator )
144146 {
145147 if ( ! IsSupportedType ( type ) )
@@ -429,8 +431,8 @@ public async Task InsertIntoTypeColumnWithArgument(string type, object value)
429431 [ DataRow ( BYTEARRAY_TYPE , "\" U3RyaW5neQ==\" " ) ]
430432 [ DataRow ( BYTEARRAY_TYPE , "\" V2hhdGNodSBkb2luZyBkZWNvZGluZyBvdXIgdGVzdCBiYXNlNjQgc3RyaW5ncz8=\" " ) ]
431433 [ DataRow ( BYTEARRAY_TYPE , "null" ) ]
432- [ DataRow ( GUID_TYPE , "\" 3a1483a5-9ac2-4998-bcf3-78a28078c6ac\" " ) ]
433- [ DataRow ( GUID_TYPE , "null" ) ]
434+ [ DataRow ( UUID_TYPE , "\" 3a1483a5-9ac2-4998-bcf3-78a28078c6ac\" " ) ]
435+ [ DataRow ( UUID_TYPE , "null" ) ]
434436 public async Task UpdateTypeColumn ( string type , string value )
435437 {
436438 if ( ! IsSupportedType ( type ) )
@@ -464,8 +466,8 @@ public async Task UpdateTypeColumn(string type, string value)
464466 [ DataRow ( DATETIME_TYPE , "1999-01-08 10:23:54" ) ]
465467 [ DataRow ( DATETIMEOFFSET_TYPE , "1999-01-08 10:23:54+8:00" ) ]
466468 [ DataRow ( BYTEARRAY_TYPE , "V2hhdGNodSBkb2luZyBkZWNvZGluZyBvdXIgdGVzdCBiYXNlNjQgc3RyaW5ncz8=" ) ]
467- [ DataRow ( GUID_TYPE , "3a1483a5-9ac2-4998-bcf3-78a28078c6ac" ) ]
468- [ DataRow ( GUID_TYPE , null ) ]
469+ [ DataRow ( UUID_TYPE , "3a1483a5-9ac2-4998-bcf3-78a28078c6ac" ) ]
470+ [ DataRow ( UUID_TYPE , null ) ]
469471 public async Task UpdateTypeColumnWithArgument ( string type , object value )
470472 {
471473 if ( ! IsSupportedType ( type ) )
@@ -511,12 +513,43 @@ private static void PerformTestEqualsForExtendedTypes(string type, string expect
511513 {
512514 CompareTimeResults ( actual . ToString ( ) , expected ) ;
513515 }
516+ else if ( type == UUID_TYPE )
517+ {
518+ CompareUuidResults ( actual . ToString ( ) , expected ) ;
519+ }
514520 else
515521 {
516522 SqlTestHelper . PerformTestEqualJsonStrings ( expected , actual . ToString ( ) ) ;
517523 }
518524 }
519525
526+ private static void CompareUuidResults ( string actual , string expected )
527+ {
528+ string fieldName = "uuid_types" ;
529+
530+ using JsonDocument actualJsonDoc = JsonDocument . Parse ( actual ) ;
531+ using JsonDocument expectedJsonDoc = JsonDocument . Parse ( expected ) ;
532+
533+ if ( actualJsonDoc . RootElement . ValueKind is JsonValueKind . Array )
534+ {
535+ ValidateArrayResults ( actualJsonDoc , expectedJsonDoc , fieldName ) ;
536+ return ;
537+ }
538+
539+ string actualUuidString = actualJsonDoc . RootElement . GetProperty ( fieldName ) . ToString ( ) ;
540+ string expectedUuidString = expectedJsonDoc . RootElement . GetProperty ( fieldName ) . ToString ( ) ;
541+
542+ // handles cases when one of the values is null
543+ if ( string . IsNullOrEmpty ( actualUuidString ) || string . IsNullOrEmpty ( expectedUuidString ) )
544+ {
545+ Assert . AreEqual ( expectedUuidString , actualUuidString ) ;
546+ }
547+ else
548+ {
549+ AssertOnFields ( fieldName , actualUuidString , expectedUuidString ) ;
550+ }
551+ }
552+
520553 /// <summary>
521554 /// HotChocolate will parse large floats to exponential notation
522555 /// while the db will return the number fully printed out. Because
@@ -701,6 +734,12 @@ private static void AssertOnFields(string field, string actualElement, string ex
701734 TimeOnly expectedTime = TimeOnly . Parse ( expectedElement . ToString ( ) ) ;
702735 Assert . AreEqual ( expectedTime . ToLongTimeString ( ) , actualTime . ToLongTimeString ( ) ) ;
703736 }
737+ else if ( field . StartsWith ( UUID_TYPE . ToLower ( ) ) )
738+ {
739+ Guid actualValue = Guid . Parse ( actualElement . ToString ( ) ) ;
740+ Guid expectedValue = Guid . Parse ( expectedElement . ToString ( ) ) ;
741+ Assert . AreEqual ( actualValue , expectedValue ) ;
742+ }
704743 else
705744 {
706745 Assert . AreEqual ( double . Parse ( expectedElement ) , double . Parse ( actualElement ) ) ;
@@ -713,11 +752,7 @@ private static void AssertOnFields(string field, string actualElement, string ex
713752 /// </summary>
714753 private static string TypeNameToGraphQLType ( string typeName )
715754 {
716- if ( typeName is GUID_TYPE )
717- {
718- return STRING_TYPE ;
719- }
720- else if ( typeName is DATETIMEOFFSET_TYPE )
755+ if ( typeName is DATETIMEOFFSET_TYPE )
721756 {
722757 return DATETIME_TYPE ;
723758 }
0 commit comments