Vincit / Vincit/objection.js

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

Open
#2,182 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
7.3k
Forks
637
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the query-builder and modifier APIs, along with the raw and joinRaw usage described in the issue. First reproduce the PostgreSQL inherited-table query with a minimal Objection.js/Knex query; done means determining whether ONLY is supported through the API or documenting the limitation and workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, postgresql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.