11using System ;
22using System . Collections . Generic ;
33using System . ComponentModel . DataAnnotations ;
4+ using System . ComponentModel . DataAnnotations . Schema ;
5+ using System . Linq ;
46
57namespace Pomelo . EntityFrameworkCore . MySql . IntegrationTests . Models
68{
@@ -101,9 +103,20 @@ public class DataTypesVariable
101103
102104 public byte [ ] TypeByteArrayN { get ; set ; }
103105
106+ [ MaxLength ( 384 ) ]
107+ [ Column ( TypeName = "vector" ) ]
108+ public float [ ] TypeVectorFloatArray { get ; set ; }
104109
105- // json not null
106- [ Required ]
110+ [ MaxLength ( 384 ) ]
111+ [ Column ( TypeName = "vector" ) ]
112+ public ReadOnlyMemory < float > TypeVectorReadonlyMemory { get ; set ; }
113+
114+ [ MaxLength ( 384 ) ]
115+ [ Column ( TypeName = "vector" ) ]
116+ public Memory < float > TypeVectorMemory { get ; set ; }
117+
118+ // json not null
119+ [ Required ]
107120 public List < string > TypeJsonArray { get ; set ; }
108121
109122 [ Required ]
@@ -117,6 +130,10 @@ public class DataTypesVariable
117130
118131 // static method to create a new empty object
119132 public static readonly byte [ ] EmptyByteArray = Array . Empty < byte > ( ) ;
133+
134+ // MariaDb requires a fully filled vector to store in the database. Using [0.0, 0.0, ..., 0.0]
135+ // as an empty vector
136+ public static readonly float [ ] EmptyFloatArray = Enumerable . Repeat ( 0.0f , 384 ) . ToArray ( ) ;
120137 public static readonly List < string > EmptyJsonArray = new List < string > ( ) ;
121138 public static readonly Dictionary < string , string > EmptyJsonObject = new Dictionary < string , string > ( ) ;
122139
@@ -128,6 +145,9 @@ public static DataTypesVariable CreateEmpty()
128145 TypeString255 = "" ,
129146 TypeByteArray = EmptyByteArray ,
130147 TypeByteArray255 = EmptyByteArray ,
148+ TypeVectorFloatArray = EmptyFloatArray ,
149+ TypeVectorMemory = EmptyFloatArray ,
150+ TypeVectorReadonlyMemory = EmptyFloatArray ,
131151 TypeJsonArray = EmptyJsonArray ,
132152 TypeJsonObject = EmptyJsonObject ,
133153 } ;
0 commit comments