File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
packages/stack/src/schema Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @cipherstash/stack " : minor
3+ ---
4+
5+ Fix data type mapping issues to EQL types.
Original file line number Diff line number Diff line change @@ -99,6 +99,22 @@ export const encryptConfigSchema = z.object({
9999 * @see {@link castAsEnum } for possible values.
100100 */
101101export type CastAs = z . infer < typeof castAsEnum >
102+
103+ // Map SDK-friendly cast names to EQL database names
104+ const castAsToEql : Record < CastAs , string > = {
105+ string : 'text' ,
106+ text : 'text' ,
107+ number : 'int' ,
108+ bigint : 'big_int' ,
109+ boolean : 'boolean' ,
110+ date : 'date' ,
111+ json : 'jsonb' ,
112+ }
113+
114+ function mapCastAs ( castAs : CastAs ) : string {
115+ return castAsToEql [ castAs ] ?? castAs
116+ }
117+
102118export type TokenFilter = z . infer < typeof tokenFilterSchema >
103119export type MatchIndexOpts = z . infer < typeof matchIndexOptsSchema >
104120export type SteVecIndexOpts = z . infer < typeof steVecIndexOptsSchema >
@@ -169,7 +185,7 @@ export class EncryptedField {
169185
170186 build ( ) {
171187 return {
172- cast_as : this . castAsValue === 'string' ? 'text' : this . castAsValue ,
188+ cast_as : mapCastAs ( this . castAsValue ) ,
173189 indexes : { } ,
174190 }
175191 }
@@ -338,7 +354,7 @@ export class EncryptedColumn {
338354
339355 build ( ) {
340356 return {
341- cast_as : this . castAsValue === 'string' ? 'text' : this . castAsValue ,
357+ cast_as : mapCastAs ( this . castAsValue ) ,
342358 indexes : this . indexesValue ,
343359 }
344360 }
You can’t perform that action at this time.
0 commit comments