objection.js icon indicating copy to clipboard operation
objection.js copied to clipboard

It is possible to add the postgres ONLY keyword to a query? (Question)

Open dgrahamlong opened this issue 4 years ago • 1 comments

Is there a way to add the ONLY keyword to a postgres query? I'm able to do it without a Model and using knex with .from(knex.raw(ONLY parent)) directly but I was wondering if it were possible to modify a query to add ONLY. For example, I'm trying to perform a query involving inherited tables like so.

SELECT * FROM ONLY parent NATURAL FULL JOIN child;

with .joinRaw, I can add the NATURAL FULL JOIN.

I tried messing around with modifiers but couldn't seem to get it to work.

dgrahamlong avatar Dec 30 '21 18:12 dgrahamlong

Knex supports this as an option on knex() also: https://knexjs.org/guide/query-builder.html#knex

Do you have a suggestion how this could be added to Objection models?

lehni avatar Apr 15 '23 09:04 lehni