Skip to content

Read views as objects under options.modifier to close #2772 - #3005

Open
mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix-2772-matrix-option-views
Open

mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix-2772-matrix-option-views

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2772

What was wrong

  • A view runs its compiled select, and that select had no modifier of its own. So it took alasql.options.modifier, and with MATRIX it returned arrays. The outer query then read every column as NULL. For an empty view it got undefined and threw Data source number 0 in undefined.
  • MATRIX returned undefined for zero rows, so an empty result was undefined and not [].

What changed

  • New helper viewRows() in 420from.js. It gives the view's select the RECORDSET modifier, as FROM subqueries already have, and returns its rows. The FROM and JOIN paths both use it.
  • MATRIX returns [] for zero rows, the same as COLUMN and the plain row form. The only visible change outside the option is MATRIX OF a query with no rows, which now gives [] in place of undefined. No existing test relied on undefined.

Tests

test/test2772.js covers a view with rows, an empty view, FROM subqueries, views in a JOIN, and a view without the option. The first four fail on develop.

yarn test-only gives 2556 pass. The only failures are the 5 Test 418 cases that load files from the internet.

# Conflicts:
#	src/420from.js
#	src/421join.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With options.modifier MATRIX, views and FROM subqueries give NULLs or throw: Data source number 0 in undefined

2 participants