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 derived column along with default fields #6979

Open
ThomasP1988 opened this issue Apr 19, 2024 · 0 comments
Open

Add derived column along with default fields #6979

ThomasP1988 opened this issue Apr 19, 2024 · 0 comments
Assignees
Labels
type:feature_request feature request

Comments

@ThomasP1988
Copy link

Describe the feature

Being able to add a derived column along with the default ones generated by Model or Dest (and joined tables)

Motivation

In my case, I would like to get a similary score with pgvector, however I would like to get it along with my model and its relationships. Select is erasing the default model querying if you add anything else than * in the function.

here is the original query I wanted to achieve:

articles := []models.AssetArticle{}
	 db.Select("*, 1 - (embedding <-> ?) AS similarity_score").Model(models.AssetArticle{}).Joins("Publisher").Omit("Embedding", "Log").Find(&articles)

the problem with this one is that Publisher won't be populated by the result.

Failed attempts:

  • I tried to first use a dry run query and copy the select clause to edit it but it is erased after the query is processed
  • I tried to write a callback but after digging into the query callback, i discovered that the whole processing is done and the query executed right after, preventing any mutation in the between

I'm happy to make a PR if you imagine a correct implementation of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature_request feature request
Projects
None yet
Development

No branches or pull requests

2 participants