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

query doesn't infer single row from selecting unique items #43

Open
alaviss opened this issue Feb 27, 2020 · 4 comments
Open

query doesn't infer single row from selecting unique items #43

alaviss opened this issue Feb 27, 2020 · 4 comments

Comments

@alaviss
Copy link
Contributor

alaviss commented Feb 27, 2020

Given a schema like this:

create table user(
  id integer primary key,
  username text unique
)

I'd expect that

let (id, username) =
  query:
    select user(id, username)
    where id == 1

or

let (id, username) =
  query:
    select user(id, username)
    where username == "alaviss"

Would work without limit 1.

The error message is also confusing:

test.nim(6, 5) Error: 'tuple' expected

Took me a moment to realize that it was trying to return a seq.

@huaxk
Copy link
Collaborator

huaxk commented Feb 28, 2020

You need limit 1, otherwise it will return a seq.

@alaviss
Copy link
Contributor Author

alaviss commented Feb 28, 2020

You need limit 1, otherwise it will return a seq.

I know. The idea is that this should not be needed, as we can clearly see from the schema that there can only be at most one element from this kind of matching.

@huaxk
Copy link
Collaborator

huaxk commented Feb 28, 2020

Ormin maybe not so smart!

@Araq
Copy link
Owner

Araq commented Mar 3, 2020

Since Ormin will never be "smart" (it's just software), easier and more predictable rules don't hurt. The limit 1 is fine. However, if you disagree and are willing to implement it, ignore me.

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

No branches or pull requests

3 participants