@@ -785,4 +785,32 @@ describe("stream", () => {
785785 expect ( page2 . isDone ) . toBe ( true ) ;
786786 } ) ;
787787 } ) ;
788+ test ( "literal undefined string works" , async ( ) => {
789+ const schema = defineSchema ( {
790+ foo : defineTable ( {
791+ a : v . optional ( v . string ( ) ) ,
792+ b : v . number ( ) ,
793+ } ) . index ( "ab" , [ "a" , "b" ] ) ,
794+ } ) ;
795+ const t = convexTest ( schema , modules ) ;
796+ await t . run ( async ( ctx ) => {
797+ await ctx . db . insert ( "foo" , { a : undefined , b : 1 } ) ;
798+ await ctx . db . insert ( "foo" , { a : "undefined" , b : 2 } ) ;
799+ const query = stream ( ctx . db , schema ) . query ( "foo" ) . withIndex ( "ab" ) ;
800+ const result = await query . paginate ( { numItems : 1 , cursor : null } ) ;
801+ expect ( result . continueCursor ) . toMatch ( '["undefined",' ) ;
802+ expect ( result . page . map ( stripSystemFields ) ) . toEqual ( [
803+ { a : undefined , b : 1 } ,
804+ ] ) ;
805+ expect ( result . isDone ) . toBe ( false ) ;
806+ const page1 = await query . paginate ( {
807+ numItems : 1 ,
808+ cursor : result . continueCursor ,
809+ } ) ;
810+ expect ( page1 . continueCursor ) . toMatch ( '["_undefined",' ) ;
811+ expect ( page1 . page . map ( stripSystemFields ) ) . toEqual ( [
812+ { a : "undefined" , b : 2 } ,
813+ ] ) ;
814+ } ) ;
815+ } ) ;
788816} ) ;
0 commit comments