Skip to content

Commit

Permalink
Merge pull request #3032 from evidence-dev/fix/query-rows-undefined-o…
Browse files Browse the repository at this point in the history
…n-page-load
  • Loading branch information
archiewood authored Jan 23, 2025
2 parents 1443383 + 77bbbfb commit 4610981
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/metal-walls-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/sdk': patch
---

Fix: Ensure that length is loaded before we returned undefined for out of range indeces
2 changes: 2 additions & 0 deletions e2e/basic/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ This page can be found in your project at `/pages/index.md`. Make a change to th
series=category
/>

The top category is {orders_by_category[0].category}

## What's Next?

- [Connect your data sources](settings)
Expand Down
5 changes: 5 additions & 0 deletions e2e/basic/sources/needful_things/connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was automatically generated
name: needful_things
type: duckdb
options:
filename: needful_things.duckdb
Binary file not shown.
1 change: 1 addition & 0 deletions e2e/basic/sources/needful_things/orders.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from orders
7 changes: 7 additions & 0 deletions e2e/basic/tests/tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ test('shows different logo in light and dark mode', async ({ page }) => {
logo = await getLogo(page);
await expect(logo).toHaveAttribute('src', '/darkLogo.png');
});

test('bare query reference', async ({ page }) => {
await page.goto('/');
await waitForPageToLoad(page);

await expect(page.getByText('The top category is Odd Equipment')).toBeVisible();
});
2 changes: 1 addition & 1 deletion packages/lib/sdk/src/usql/query/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ DESCRIBE ${this.text.trim()}
if (target === null)
if (typeof prop !== 'number') return undefined;
else {
if (prop > this.#length) return undefined;
if (this.lengthLoaded && prop > this.#length) return undefined;
return this.#mockRow ?? {};
}

Expand Down

0 comments on commit 4610981

Please sign in to comment.