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

fixed comment for example sql statement #47929

Merged
merged 1 commit into from
Apr 12, 2023
Merged

fixed comment for example sql statement #47929

merged 1 commit into from
Apr 12, 2023

Conversation

jetjodh
Copy link
Contributor

@jetjodh jetjodh commented Apr 12, 2023

Motivation / Background

This Pull Request has been created because fixes #47903

Detail

This Pull Request changes example SQL statement to be more coherent to the user.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@vipulnsward
Copy link
Member

vipulnsward commented Apr 12, 2023

The current example is correct. For example-

> User.joins(:devices).ids
=> User Pluck (3.5ms)  SELECT "users"."id" FROM "users" INNER JOIN "devices" ON "devices"."user_id" = "users"."id"

Did this produce a different response for you?

@zzak
Copy link
Member

zzak commented Apr 12, 2023

@vipulnsward Either is "correct", it depends on the association right? In this case saying "this person belongs to this company" is more natural than "this company belongs to this person", IMO. I guess the reference could be a table of CEOs!

@zzak
Copy link
Member

zzak commented Apr 12, 2023

I think here is another good example, ignoring the second join:

```ruby
Book.joins(:author, :reviews)
```
This produces:
```sql
SELECT books.* FROM books
INNER JOIN authors ON authors.id = books.author_id

@zzak zzak merged commit 767653a into rails:main Apr 12, 2023
8 checks passed
@vipulnsward
Copy link
Member

Sounds good, I generally go with the generated console output instead of what looks better, since many open PRs sometimes saying its wrong.

@zzak
Copy link
Member

zzak commented Apr 12, 2023

Sounds good, I generally go with the generated console output instead of what looks better, since many open PRs sometimes saying its wrong.

In this case the output is generated from models we don't actually have access to the full schema though, right? So we're kind of making things up as we go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An improvement for an example from Ruby On Rails API website
3 participants