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

Nested Select Queries #769

Open
iSwiftter opened this issue Jan 3, 2018 · 1 comment
Open

Nested Select Queries #769

iSwiftter opened this issue Jan 3, 2018 · 1 comment

Comments

@iSwiftter
Copy link

iSwiftter commented Jan 3, 2018

I have a tree like scheme where the items can have parent from the same table what I need is to query the items whose parent is deleted

select * from items as c where not exists (select p.id from items as p where c.parent_id == p.id)

I tried to achieve this as :

let child = ItemTable.table.alias("child")
let parent = ItemTable.table.alias("parent")
let parentExists = parent.filter(child[ItemTable.parentId] == parent[ItemTable.id]).exists
let r = child.filter(parentExists)

but the last line gives the following compilation error :

Cannot invoke 'filter' with an argument list of type '(Select<Bool>)'

I can write the whole code in sql and run the query, but I need to achieve this using the ORM provided by SQLite Swift.

@adamg89
Copy link

adamg89 commented Jan 28, 2025

Any solution for this?

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

2 participants