Fix conflicting annotations for multiple-database scenario#892
Fix conflicting annotations for multiple-database scenario#892afn wants to merge 1 commit intoctran:developfrom
Conversation
pkopac
left a comment
There was a problem hiding this comment.
Our app also got affected, I had to temporarily disable other databases to be able to annotate correctly.
Given a Rails application with multiple databases, tables in two databases with the same table name, and corresponding models with different names, some files get annotated with the wrong table's schema. The issue is that some of the patterns include `%TABLE_NAME%`, which will be identical between the two tables, even though they have different model names. This fixes the issue by eliminating the use of the table name when the model is not connected to the primary database. Fixes ctran#891.
845978f to
3ab4ab5
Compare
|
@afn sorry to hijack the thread a bit, but if you're interested I could get this added to my fork https://github.com/drwl/annotaterb. Since I'm still on the list of maintainers for this gem I get pinged about activity by Github every now and then. I would just need instructions on setting up a proof of concept Rails app with the case you're talking about (multiple databases + models with same table name). |
|
Thanks @drwl! I've pushed an example app to https://github.com/cygnuseducation/annotate-test-app. This test case doesn't actually end up incorrectly annotating the files, but it does incorrectly detect that there are relevant changes to the annotations: See also the integration test in 385c293. Thanks! |
|
@afn would you mind if we continued discussions in drwl/annotaterb#135? |
Given a Rails application with multiple databases, tables in two databases with the same table name, and corresponding models with different names, some files get annotated with the wrong table's schema.
The issue is that some of the patterns include
%TABLE_NAME%, which will be identical between the two tables, even though they have different model names.This fixes the issue by eliminating the use of the table name when the model is not connected to the primary database.
Fixes #891.