Skip to content
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

fix(zql): Fix type of IN/LIKE operators #59

Merged
merged 2 commits into from
Apr 6, 2024
Merged

fix(zql): Fix type of IN/LIKE operators #59

merged 2 commits into from
Apr 6, 2024

Conversation

arv
Copy link
Contributor

@arv arv commented Apr 3, 2024

The RHS of IN needs to be an array
The RHS of LIKE/ILIKE needs to be a string

The RHS of IN needs to be an array
The RHS of LIKE/ILIKE needs to be a string
@arv arv requested a review from tantaman April 3, 2024 21:40
Op extends SimpleOperator,
> = S['fields'][K] extends Primitive | undefined
? Op extends InOps
? NotUndefined<S['fields'][K]>[]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to not allow undefined in these cases.

I guess it could be argued that we should allow it for = and !=?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should think about what we want here when it comes to representing optional values in PSQPL.

Copy link

@tantaman tantaman Apr 4, 2024

Choose a reason for hiding this comment

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

null is another thing we need to think about. Unfortunately SQL has odd rules around null when it comes to equality.

sqlite> create table foo (a);
sqlite> insert into foo values (null);
sqlite> .mode qbox
sqlite> select * from foo;
┌──────┐
│  a   │
├──────┤
│ NULL │
└──────┘
sqlite> select * from foo where a = null;
sqlite> select * from foo where a != null;
sqlite> select * from foo where a IS null;
┌──────┐
│  a   │
├──────┤
│ NULL │
└──────┘
sqlite> select * from foo where a IS NOT null;
sqlite>
sqlite> insert into foo values (1);
sqlite> select * from foo where a != null;
sqlite> select * from foo;
┌──────┐
│  a   │
├──────┤
│ NULL │
│ 1    │
└──────┘

@arv arv merged commit 8e2384f into main Apr 6, 2024
4 checks passed
@arv arv deleted the arv/zql-in-type branch April 6, 2024 20:49
arv added a commit that referenced this pull request Apr 8, 2024
The RHS of IN needs to be an array
The RHS of LIKE/ILIKE needs to be a string
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