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

do not add extra s after table name when generating array relationship name #1072

Closed
wants to merge 1 commit into from

Conversation

elitan
Copy link
Contributor

@elitan elitan commented Nov 20, 2018

…p name

Description

do not add extra s after table name when generating array relationship name

What component does this PR affect?

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System

Requires changes from other components? If yes, please mark the components:

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System

Related Issue

None

Solution and Design

Some (most) use plural when naming their tables. This make the extra added, hard coded, s after a table name confusing. Even if the tables are named in singular, just adding a s in the end is not the correct plural naming. Like company which in plural is companies. Just adding a s in the end would result in an incorrect naming: companys.

Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs update
  • Community content

Checklist:

  • I have read the contributing guide and my code conforms to the guidelines.
  • This change requires a change in the documentation.
  • I have updated the documentation accordingly.
  • I have added required tests.

@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @elitan, thanks for your PR!

One of my human friends will review this PR and get back to you as soon as possible. 🕐

Stay awesome! 😎

@CLAassistant
Copy link

CLAassistant commented Nov 20, 2018

CLA assistant check
All committers have signed the CLA.

@elitan
Copy link
Contributor Author

elitan commented Nov 20, 2018

hmm, do I have to take any further action on this?

@shahidhk
Copy link
Member

Hi @elitan, thanks for the contribution 🙏

The change you have added is for community/tools/json2graphql, which is different from the console.

@praveenweb @karthikvt26, can you point @elitan to the right place where he needs to make this change?

My suggestion is that we add a s for array realationships if the table name doesn't end with a s already (e.g. order -> ordersByUserId). If the table name already contains s, we don't add another s (e.g. orders -> ordersByUserId).

@shahidhk shahidhk added the c/console Related to console label Nov 21, 2018
@shahidhk shahidhk changed the title do not add extra s after table name when generating array relationshi… do not add extra s after table name when generating array relationship name Nov 21, 2018
@elitan
Copy link
Contributor Author

elitan commented Nov 21, 2018

Ok, yes please nock me in the right direction. :)

But first maybe we should discuss if we should or shouldn't add the extra s. As I described above, English is more complex than just add a s in the end to transform any world to its plural form.

With your idea with adding a s if the word does not end with s does not work if you would name your tables in singular form and use, let's say, company.

This would result in companysBy... Not very pretty nor correct.

@shahidhk
Copy link
Member

Makes sense @elitan. What about using something like pluralize? It should cover most of the use cases, right?

For array relationships, we take the remote table, pluralize it, and then append the ByColumnName. 🤔

@elitan
Copy link
Contributor Author

elitan commented Nov 21, 2018

That could work, but I do see some problems with it. As you say it would probably work "in most cases". Aslo you would have problem if you name your tables in another language than English.

I understand you want to make it as easy as possible for users when naming relations between tables. But as a developer you also want to be, or feel like you are, in full control. For me, when Hasura tries to be smart like this, and fail, it is frustrating.

And if Hasura would be somewhat successful in 'guessing' the correct name on relations I would expect Hasura to also enforce singular naming on table names for consistency. Further I would expect all query names to have the plural format as well since, if I am not misstaken, all queries return an array of objects.

Ex:

Table name: company
RelationShip: companiesBy...
Query: companies () {...

I suggest that Hasura would suggest to use plural format when naming tables, and remove any automatic/smart conversion when generating relationship names.

@shahidhk
Copy link
Member

@elitan Sorry, lost track of this issue. @praveenweb What do you think?

@praveenweb
Copy link
Member

@shahidhk @elitan - Related issue #1444 .

The idea is to generate singular names for object relationships and plural names for array relationships using the inflection module.

We can close this PR.

@shahidhk
Copy link
Member

Thanks for the PR @elitan, as @praveenweb mentioned, we'll use the node module inflection to do this. Feel free to take up #1444 if you are interested 😄

@shahidhk shahidhk closed this Jan 24, 2019
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-1072.herokuapp.com is deleted

hasura-bot pushed a commit that referenced this pull request Sep 9, 2024
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.16 to 4.5.17.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/releases">clap's
releases</a>.</em></p>
<blockquote>
<h2>v4.5.17</h2>
<h2>[4.5.17] - 2024-09-04</h2>
<h3>Fixes</h3>
<ul>
<li><em>(help)</em> Style required argument groups</li>
<li><em>(derive)</em> Improve error messages when unsupported fields are
used</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/blob/master/CHANGELOG.md">clap's
changelog</a>.</em></p>
<blockquote>
<h2>[4.5.17] - 2024-09-04</h2>
<h3>Fixes</h3>
<ul>
<li><em>(help)</em> Style required argument groups</li>
<li><em>(derive)</em> Improve error messages when unsupported fields are
used</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/clap-rs/clap/commit/6013ad4f676dd25c5b5150557a5fb5698c3de020"><code>6013ad4</code></a>
chore: Release</li>
<li><a
href="https://github.com/clap-rs/clap/commit/f98e3ee215015055d776f91217019c33da78c975"><code>f98e3ee</code></a>
docs: Update changelog</li>
<li><a
href="https://github.com/clap-rs/clap/commit/addec17e9df4f4f64a959bbe6ab8c9ced48c6a3d"><code>addec17</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5681">#5681</a>
from epage/static</li>
<li><a
href="https://github.com/clap-rs/clap/commit/3c69aaa312af1b537ccd291314b60500ab5066c4"><code>3c69aaa</code></a>
docs(complete): Add stdout warning to env</li>
<li><a
href="https://github.com/clap-rs/clap/commit/e46263a0480f7bc7ab085e966a1eee1287e4303b"><code>e46263a</code></a>
docs(complete): Redistribute dynamic's documentation</li>
<li><a
href="https://github.com/clap-rs/clap/commit/de723aaf8a81402c4543f73118466c72c95653fb"><code>de723aa</code></a>
fix(complete)!: Flatten in prep for stabilization</li>
<li><a
href="https://github.com/clap-rs/clap/commit/6727c1537b9e8c26a27efefad6e55106f25e0b1c"><code>6727c15</code></a>
fix(complete): Section off existing completions</li>
<li><a
href="https://github.com/clap-rs/clap/commit/6842ed96da9d7307e340ac82bc2d6fd27a591f9d"><code>6842ed9</code></a>
refactor(complete): Remove low-value w macro</li>
<li><a
href="https://github.com/clap-rs/clap/commit/17d6d2423292610827559be0e361035aeb42092a"><code>17d6d24</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5680">#5680</a>
from epage/unstable</li>
<li><a
href="https://github.com/clap-rs/clap/commit/23fb0568a861a34fb60b95c916f0aa9d8dbe7e24"><code>23fb056</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5679">#5679</a>
from epage/api</li>
<li>Additional commits viewable in <a
href="https://github.com/clap-rs/clap/compare/clap_complete-v4.5.16...clap_complete-v4.5.17">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=clap&package-manager=cargo&previous-version=4.5.16&new-version=4.5.17)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)

</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
V3_GIT_ORIGIN_REV_ID: 49b80a6725973f691e34caf8e89750cf6765bc70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/console Related to console
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants