28
28
29
29
"""VECTOR Type Tests."""
30
30
31
- import asyncio
32
31
import datetime
33
32
import math
33
+ import os
34
+ import platform
34
35
import struct
35
36
import unittest
36
37
45
46
from mysql .connector .errors import DatabaseError , InterfaceError , ProgrammingError
46
47
47
48
49
+ LOCAL_PLATFORM = platform .platform ().lower () if hasattr (platform , "platform" ) else ""
50
+ PLATFORM_IS_SOLARIS = "sunos-" in LOCAL_PLATFORM
51
+
52
+
48
53
@unittest .skipIf (
49
54
tests .MYSQL_VERSION < (9 , 0 , 0 ),
50
55
"MySQL Server 8.4.0 and older don't support VECTOR types." ,
@@ -431,11 +436,22 @@ def test_ingest_big_endian_encoding(self):
431
436
432
437
Expect no error but a mismatch between the original sequence and the returned one.
433
438
"""
439
+ byte_order = ">" # big-endian - true for most modern architectures
440
+ err_msg = ""
441
+ if PLATFORM_IS_SOLARIS :
442
+ # for some legacy architectures "<" must be used to indicate big-endian
443
+ _ , _ , _ , _ , arch = os .uname ()
444
+ if "sun4v" in arch .lower ():
445
+ byte_order = "<"
446
+ err_msg = (
447
+ f"Solaris with { arch } architecture using byte-order '{ byte_order } '"
448
+ )
449
+
434
450
record_id = 6
435
451
row = [
436
452
record_id ,
437
453
struct .pack (
438
- f"> { len (self .v1 )} f" , * (tuple (self .v1 ))
454
+ f"{ byte_order } { len (self .v1 )} f" , * (tuple (self .v1 ))
439
455
).hex (), # BigEndian encoding
440
456
"Mario" ,
441
457
datetime .date (1967 , 3 , 17 ),
@@ -462,7 +478,7 @@ def test_ingest_big_endian_encoding(self):
462
478
463
479
self .assertEqual (field_type , FieldType .VECTOR )
464
480
self .assertIsInstance (v , exp_instance )
465
- self .assertNotEqual (v , self .v1 )
481
+ self .assertNotEqual (v , self .v1 , err_msg )
466
482
467
483
@tests .foreach_cnx ()
468
484
def test_vector_max_dim (self ):
@@ -889,11 +905,22 @@ async def test_ingest_big_endian_encoding(self):
889
905
890
906
Expect no error but a mismatch between the original sequence and the returned one.
891
907
"""
908
+ byte_order = ">" # big-endian - true for most modern architectures
909
+ err_msg = ""
910
+ if PLATFORM_IS_SOLARIS :
911
+ # for some legacy architectures "<" must be used to indicate big-endian
912
+ _ , _ , _ , _ , arch = os .uname ()
913
+ if "sun4v" in arch .lower ():
914
+ byte_order = "<"
915
+ err_msg = (
916
+ f"Solaris with { arch } architecture using byte-order '{ byte_order } '"
917
+ )
918
+
892
919
record_id = 6
893
920
row = [
894
921
record_id ,
895
922
struct .pack (
896
- f"> { len (self .v1 )} f" , * (tuple (self .v1 ))
923
+ f"{ byte_order } { len (self .v1 )} f" , * (tuple (self .v1 ))
897
924
).hex (), # BigEndian encoding
898
925
"Mario" ,
899
926
datetime .date (1967 , 3 , 17 ),
@@ -922,7 +949,7 @@ async def test_ingest_big_endian_encoding(self):
922
949
923
950
self .assertEqual (field_type , FieldType .VECTOR )
924
951
self .assertIsInstance (v , exp_instance )
925
- self .assertNotEqual (v , self .v1 )
952
+ self .assertNotEqual (v , self .v1 , err_msg )
926
953
927
954
@tests .foreach_cnx ()
928
955
async def test_vector_max_dim (self ):
0 commit comments