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

only replace '_id' at end of columnName #7684

Merged
merged 1 commit into from
Nov 15, 2019
Merged

only replace '_id' at end of columnName #7684

merged 1 commit into from
Nov 15, 2019

Conversation

rharink
Copy link
Contributor

@rharink rharink commented Apr 17, 2019

I've encountered a problem with foreign-key column-names that have a '_id' (e.g. _identity) in their name.
These columns don't get renamed properly (partner_identity_card -> partnerentityCard).

The fix could be a preg_replace instead of a string_replace that only replaces the _id at the end of a column name.

@rharink
Copy link
Contributor Author

rharink commented Apr 17, 2019

Could someone point me in the right direction for creating a test-case? I would need a (mock) driver that supports foreign-keys

@Ocramius
Copy link
Member

@rharink check https://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ORM/Functional/Ticket for examples of test cases.

I'd suggest a scenario that runs on SQLite only and:

  1. creates a table
  2. instantiates the DatabaseDriver
  3. verifies the schema information coming from DatabaseDriver

@rharink
Copy link
Contributor Author

rharink commented Apr 17, 2019

@Ocramius Thanks for the reply,

The SqlLite driver doesn't support foreign keys. The DatabaseDriver class will not resolve foreign keys, thus the method getFieldNameForColumn is never called in the testcase.

returns false for Sqllite

$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints())

@Ocramius
Copy link
Member

True, would need to design this with MySQL or equivalent

@rharink
Copy link
Contributor Author

rharink commented Apr 17, 2019

Should I use a DbalFunctionalTestCase or is there something else I can use to setup a MySQL test?
Thanks for the help!

@rharink
Copy link
Contributor Author

rharink commented Apr 17, 2019

Sorry should read more before asking ;) I found documentation on how to run tests on mysql.

@rharink
Copy link
Contributor Author

rharink commented Apr 18, 2019

@Ocramius Checks have passed, should / can I do anything else?

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good: needs adjustments in test naming and placing (need to check if we can turn this into a full unit tests, eventually - not sure if that is feasible)

@rharink
Copy link
Contributor Author

rharink commented Apr 23, 2019

@Ocramius can I do something else? maybe add a unit test in the databaseDriverTest.php? Just let me know

Ocramius
Ocramius previously approved these changes May 27, 2019
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@rharink can you rebase on top of upstream/2.6 so that we can see if the CI failures are related to this patch at all?

Besides that, just needs a merge from our end.

@Ocramius Ocramius added this to the 2.6.4 milestone May 27, 2019
@rharink
Copy link
Contributor Author

rharink commented May 28, 2019

Ok, I've merged upstream.

@greg0ire
Copy link
Member

I rebased, I fixed the build in #7731, this means the tests might now pass.

Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case is unfortunately not correct. It passes for previous behaviour too.

@greg0ire
Copy link
Member

Wow good catch! Well at least the build is green now 😅

@rharink please look into this 🙏

@rharink
Copy link
Contributor Author

rharink commented Nov 15, 2019

Good one! Ill look in to it.

@lcobucci
Copy link
Member

@ostrolucky nice catch indeed, thanks!

@rharink since we're aiming at releasing the last patch of the 2.6.x series and release 2.7.0 I'm moving this to 2.7.1 so we don't put a lot of pressure on your shoulders 😄

Thanks for putting effort into this and I hope we can solve it together in the next patch 👍

@lcobucci lcobucci modified the milestones: 2.6.5, 2.7.1 Nov 15, 2019
@rharink
Copy link
Contributor Author

rharink commented Nov 15, 2019

I've improved the unit-test. it didn't pass for previous behaviour as the key gh7684IdentityTest in the associationMapping would not have been present. Or am i interpreting 'previous behaviour' wrong 😅

ostrolucky
ostrolucky previously approved these changes Nov 15, 2019
Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is correct now. @lcobucci I would say we can merge this now to 2.6.5 what do you say?

@greg0ire
Copy link
Member

Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble.

How to do that?

  1. git rebase -i origin/2.6, assuming origin is a git remote that points to this repository, and not your fork. If you're not sure what your remotes are, run git remote -vvv, there should be your fork and the holy/reference/base/origin/whatever-you-call-it repository.
  2. A window will show up with many lines, replace pick with fixup on every line but the first one
  3. Close your editor, git should do its magic, and you should end up with one commit
  4. Use git push --force to overwrite what you already push. Don't forget the --force option otherwise git will try to merge both things together.

@lcobucci
Copy link
Member

@rharink @ostrolucky awesome, thanks for being that quick. Please follow @greg0ire's instructions and let's ship this!

@lcobucci lcobucci modified the milestones: 2.7.1, 2.6.5 Nov 15, 2019
@rharink
Copy link
Contributor Author

rharink commented Nov 15, 2019

@lcobucci @ostrolucky done, lets go!

@lcobucci lcobucci merged commit c83094b into doctrine:2.6 Nov 15, 2019
@lcobucci
Copy link
Member

@rharink 🚢

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

Successfully merging this pull request may close these issues.

None yet

5 participants