Skip to content

Fix v and nv filters in SQL #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2022
Merged

Fix v and nv filters in SQL #340

merged 1 commit into from
Dec 16, 2022

Conversation

annie
Copy link
Contributor

@annie annie commented Dec 16, 2022

This fixes a bug where v and nv filters don't work for SQL data sources 😬 The issue is that, because we handle those filters in the binary operation conditional block, we append the primitive value (which contains the expected type) to the SQL query https://github.com/observablehq/stdlib/blob/main/src/table.js#L420. You end up with a query with broken syntax in the WHERE clause:

Screen Shot 2022-12-16 at 13 06 59

We should just consider v and nv to be unary operations (I think it was originally my suggestion to handle them in the binary op block so that's my bad!!). I also added a unit test for this case.

@annie annie requested review from mkfreeman and mbostock December 16, 2022 18:13
Copy link
Contributor

@mkfreeman mkfreeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for catching that and adding a test!

@annie annie merged commit 0d3a2bb into main Dec 16, 2022
@annie annie deleted the annie/fix-v-nv-sql branch December 16, 2022 18:32
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.

2 participants