dataform icon indicating copy to clipboard operation
dataform copied to clipboard

Bug with SQL template variables when action inside while loop

Open max-ostapenko opened this issue 5 months ago • 0 comments

When iterating an operation over the months I'm using while loop and a dynamic date variable in the SQL template.

I see something strange happens to the iterator variable within the SQL template.

Example:

let i = 0;
while (i <= 1) {
    operate(`while ${i}`).queries(ctx => `
        SELECT '${i}' AS value
    `);

    i++;
}

I get the following compiled SQLs:

  1. Operation "while 0"
SELECT '2' AS value
  1. Operation "while 1"
SELECT '2' AS value
  • forEach and for loops work OK,
  • without ctx => it works OK too.

Originally reported here: https://issuetracker.google.com/issues/365808530

max-ostapenko avatar Sep 11 '24 16:09 max-ostapenko