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

Returning to support expressions and queries #130

Open
martijndeh opened this issue Sep 27, 2020 · 0 comments
Open

Returning to support expressions and queries #130

martijndeh opened this issue Sep 27, 2020 · 0 comments
Labels
good first issue Good for newcomers

Comments

@martijndeh
Copy link
Contributor

The .returning() function currently only supports strings (which should be the target table's column names). In reality they can accept any expression and (returning) query.

This should be supported:

insert into bar (val) values (123) returning (select count(*) from bar), id, val || 'test'

which would equate to something like:

db.insertInto(bar).values({ val: 123 }).returning(db.select(count()).from(bar), concat(bar.val, `test`).as(`test`))

The returning function is used in insert, update and delete queries. So probably best to focus on getting one of those working. And later maybe create some reusable type if that's at all possible similar to something like SelectFn.

The return type in ResultSet<Returning, Test> probably already supports getting the type right.

@martijndeh martijndeh added the good first issue Good for newcomers label Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant