@@ -29,7 +29,7 @@ type EncryptedColumn struct {
2929 P string `json:"p"`
3030 I TableColumn `json:"i"`
3131 V int `json:"v"`
32- Q any `json:"q"`
32+ Q string `json:"q"`
3333}
3434
3535// EncryptedText is a string value to be encrypted
@@ -46,7 +46,7 @@ type EncryptedBool bool
4646
4747// Serialize turns a EncryptedText value into a jsonb payload for CipherStash Proxy
4848func (et EncryptedText ) Serialize (table string , column string ) ([]byte , error ) {
49- val , err := ToEncryptedColumn (string (et ), table , column , nil )
49+ val , err := ToEncryptedColumn (string (et ), table , column )
5050 if err != nil {
5151 return nil , fmt .Errorf ("error serializing: %v" , err )
5252 }
@@ -69,7 +69,7 @@ func (et *EncryptedText) Deserialize(data []byte) (EncryptedText, error) {
6969
7070// Serialize turns a EncryptedJsonb value into a jsonb payload for CipherStash Proxy
7171func (ej EncryptedJsonb ) Serialize (table string , column string ) ([]byte , error ) {
72- val , err := ToEncryptedColumn (map [string ]any (ej ), table , column , nil )
72+ val , err := ToEncryptedColumn (map [string ]any (ej ), table , column )
7373 if err != nil {
7474 return nil , fmt .Errorf ("error serializing: %v" , err )
7575 }
@@ -97,7 +97,7 @@ func (ej *EncryptedJsonb) Deserialize(data []byte) (EncryptedJsonb, error) {
9797
9898// Serialize turns a EncryptedInt value into a jsonb payload for CipherStash Proxy
9999func (et EncryptedInt ) Serialize (table string , column string ) ([]byte , error ) {
100- val , err := ToEncryptedColumn (int (et ), table , column , nil )
100+ val , err := ToEncryptedColumn (int (et ), table , column )
101101 if err != nil {
102102 return nil , fmt .Errorf ("error serializing: %v" , err )
103103 }
@@ -124,7 +124,7 @@ func (et *EncryptedInt) Deserialize(data []byte) (EncryptedInt, error) {
124124
125125// Serialize turns a EncryptedBool value into a jsonb payload for CipherStash Proxy
126126func (eb EncryptedBool ) Serialize (table string , column string ) ([]byte , error ) {
127- val , err := ToEncryptedColumn (bool (eb ), table , column , nil )
127+ val , err := ToEncryptedColumn (bool (eb ), table , column )
128128 if err != nil {
129129 return nil , fmt .Errorf ("error serializing: %v" , err )
130130 }
@@ -171,7 +171,7 @@ func JsonbQuery(value any, table string, column string) ([]byte, error) {
171171}
172172
173173// serializeQuery produces a jsonb payload used by EQL query functions to perform search operations like equality checks, range queries, and unique constraints.
174- func serializeQuery (value any , table string , column string , queryType any ) ([]byte , error ) {
174+ func serializeQuery (value any , table string , column string , queryType string ) ([]byte , error ) {
175175 query , err := ToEncryptedColumn (value , table , column , queryType )
176176 if err != nil {
177177 return nil , fmt .Errorf ("error converting to EncryptedColumn: %v" , err )
@@ -186,14 +186,14 @@ func serializeQuery(value any, table string, column string, queryType any) ([]by
186186}
187187
188188// ToEncryptedColumn converts a plaintext value to a string, and returns the EncryptedColumn struct for inserting into a database.
189- func ToEncryptedColumn (value any , table string , column string , queryType any ) (EncryptedColumn , error ) {
189+ func ToEncryptedColumn (value any , table string , column string , queryType ... string ) (EncryptedColumn , error ) {
190190 str , err := convertToString (value )
191191 if err != nil {
192192 return EncryptedColumn {}, fmt .Errorf ("error: %v" , err )
193193 }
194194 data := EncryptedColumn {K : "pt" , P : str , I : TableColumn {T : table , C : column }, V : 1 }
195195 if queryType != nil {
196- data .Q = queryType
196+ data .Q = queryType [ 0 ]
197197 }
198198 return data , nil
199199}
0 commit comments