ctran / annotate_models

Annotate Rails classes with schema and routes info
Other
4.41k stars 598 forks source link

Fix annotation when a table_name_prefix is in use #1003

Open clottman opened 8 months ago

clottman commented 8 months ago

Expected behavior:

If a table has a table name prefix, I can annotate it.

Current behavior:

Annotation fails because it's trying to use the unprefixed table name when getting the indexes.

Fix explanation

In retrieve_indexes_from_table, klass.table_name already contains the prefix if one exists. So, we shouldn't need to check separately for the prefixed or unprefixed version.

Tests

I tried to add tests; there is one failing and I'm not sure what the expected behavior is there/how to fix it. (Unclear to me if it's a test-specific failure or the fix I am suggesting doesn't work for this particular case).

Related issues

Seems related possibly to https://github.com/ctran/annotate_models/issues/967 and this comment - we were seeing the same error message as that user.