Skip to content

Quote “user” table in example code with backticks #9551

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

Closed
wants to merge 1 commit into from
Closed

Quote “user” table in example code with backticks #9551

wants to merge 1 commit into from

Conversation

msheakoski
Copy link
Contributor

Naming the table “user” without backtick quoting will trigger an error for anybody that copy/pastes the code because “USER” is a SQL reserved word. See #9541 for more details.

Naming the table “user” without backtick quoting will trigger an error for anybody that copy/pastes the code because “USER” is a SQL reserved word. See #9541 for more details.
@xabbuh xabbuh added this to the 2.8 milestone Apr 5, 2018
@xabbuh
Copy link
Member

xabbuh commented Apr 5, 2018

What do you think if we rename the table to users instead?

@msheakoski
Copy link
Contributor Author

My reasoning for keeping `user` would be:

  1. Doctrine, by default, uses the same table name as the class name
  2. the reason for backticks is covered in the "storing users in a database" section which will probably be read before the guard section
  3. it invites the reader to research the topic more and learn something new instead of hiding it from them

However, if the docs team prefers using the plural form, I don't have any strong feelings about it and can change it. Another option would be adding a little note like in #9541 and FOSUserBundle.

@javiereguiluz
Copy link
Member

There are lots of issues about this everywhere: GitHub, StackOverflow, etc. I wish Doctrine could solve this. Apparently they can't (https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases) because of "legacy databases" ... but I wish they could. Developers shouldn't care about this: if something needs to be escaped, it should be automatically escaped 😢

Back to our docs, my preference would be to keep the quoted user table name ... but add a .. caution:: directive before or after this code to explain this issue once more to the readers.

@msheakoski
Copy link
Contributor Author

Back to our docs, my preference would be to keep the quoted user table name ... but add a .. caution:: directive before or after this code to explain this issue once more to the readers.

Got it. I will update the PR with the caution wording taken from the other two PRs that I referenced.

@javiereguiluz
Copy link
Member

Ping @msheakoski so you don't forget about this 😄 Thanks!

@wouterj
Copy link
Member

wouterj commented May 5, 2018

Hi @msheakoski! I've gone ahead and merged this PR and add a modified version of your previous caution afterwards in 99fa4a1 . Please submit a new PR or add a comment here if you want to modify the wording or don't agree with the changes :)

Thanks a lot for your recent security doc contributions!

@wouterj wouterj closed this in 1795bd7 May 5, 2018
@msheakoski
Copy link
Contributor Author

Thank you for adding that @wouterj, I think it looks great!

javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request May 6, 2018
* 2.8:
  [symfony#9551] Added caution directive explaining the backticks
  Quote “user” table in example code with backticks
  Adding guidelines for reporting violations of code of conduct
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.

5 participants