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

Add Relational.only function, which allows scalar sub-queries #62

Closed
julianhyde opened this issue Aug 30, 2021 · 1 comment
Closed

Add Relational.only function, which allows scalar sub-queries #62

julianhyde opened this issue Aug 30, 2021 · 1 comment

Comments

@julianhyde
Copy link
Collaborator

julianhyde commented Aug 30, 2021

Add Relational.only function, of type α list → α, which returns the sole element of a list, and throws if the list is empty or has more than one element.

The equivalent of the SQL query

SELECT e.ename,
  (SELECT d.dname FROM depts AS d WHERE d.deptno = e.deptno) AS dname
FROM emps AS e

will be

from e in emps
  yield {ename = e.name,
         dname = only (from d in depts
                       where d.deptno = e.deptno
                       yield d.name)}
@julianhyde
Copy link
Collaborator Author

Fixed in bb060be.

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

1 participant