@@ -29,7 +29,7 @@ type EncryptedColumn struct {
29
29
P string `json:"p"`
30
30
I TableColumn `json:"i"`
31
31
V int `json:"v"`
32
- Q any `json:"q"`
32
+ Q string `json:"q"`
33
33
}
34
34
35
35
// EncryptedText is a string value to be encrypted
@@ -46,7 +46,7 @@ type EncryptedBool bool
46
46
47
47
// Serialize turns a EncryptedText value into a jsonb payload for CipherStash Proxy
48
48
func (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 )
50
50
if err != nil {
51
51
return nil , fmt .Errorf ("error serializing: %v" , err )
52
52
}
@@ -69,7 +69,7 @@ func (et *EncryptedText) Deserialize(data []byte) (EncryptedText, error) {
69
69
70
70
// Serialize turns a EncryptedJsonb value into a jsonb payload for CipherStash Proxy
71
71
func (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 )
73
73
if err != nil {
74
74
return nil , fmt .Errorf ("error serializing: %v" , err )
75
75
}
@@ -97,7 +97,7 @@ func (ej *EncryptedJsonb) Deserialize(data []byte) (EncryptedJsonb, error) {
97
97
98
98
// Serialize turns a EncryptedInt value into a jsonb payload for CipherStash Proxy
99
99
func (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 )
101
101
if err != nil {
102
102
return nil , fmt .Errorf ("error serializing: %v" , err )
103
103
}
@@ -124,7 +124,7 @@ func (et *EncryptedInt) Deserialize(data []byte) (EncryptedInt, error) {
124
124
125
125
// Serialize turns a EncryptedBool value into a jsonb payload for CipherStash Proxy
126
126
func (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 )
128
128
if err != nil {
129
129
return nil , fmt .Errorf ("error serializing: %v" , err )
130
130
}
@@ -171,7 +171,7 @@ func JsonbQuery(value any, table string, column string) ([]byte, error) {
171
171
}
172
172
173
173
// 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 ) {
175
175
query , err := ToEncryptedColumn (value , table , column , queryType )
176
176
if err != nil {
177
177
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
186
186
}
187
187
188
188
// 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 ) {
190
190
str , err := convertToString (value )
191
191
if err != nil {
192
192
return EncryptedColumn {}, fmt .Errorf ("error: %v" , err )
193
193
}
194
194
data := EncryptedColumn {K : "pt" , P : str , I : TableColumn {T : table , C : column }, V : 1 }
195
195
if queryType != nil {
196
- data .Q = queryType
196
+ data .Q = queryType [ 0 ]
197
197
}
198
198
return data , nil
199
199
}
0 commit comments