Skip to content

Multiple cursors on single transaction not supported. #65

Closed
@McAronDev

Description

@McAronDev
  await sql.begin((tx:any)=>{
    return Promise.all([
      tx`select 1 as cursor, x from generate_series(1,4) as x`.cursor(async (row: any[])=>{
        console.log('cursor1' , JSON.stringify(row));
        await new Promise(resolve=>setTimeout(resolve, 2000));
      }),
      tx`select 2 as cursor, x from generate_series(101,104) as x`.cursor(async (row: any[])=>{
        console.log('cursor2' , JSON.stringify(row));
        await new Promise(resolve=>setTimeout(resolve, 1000));
      })
    ]);
  });

This code returns unexpected console output:

cursor1 {"cursor":1,"x":1}
cursor1 {"cursor":2,"x":101}
cursor1 {"cursor":2,"x":102}
cursor1 {"cursor":2,"x":103}
cursor1 {"cursor":2,"x":104}

is it possible to support simultaneous reading for multiple cursors in single transaction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions