cycle / annotated

Schema generation using annotated entities and mappers
MIT License
23 stars 12 forks source link

Initial implementation for class table inheritance #13

Closed armpogart closed 2 years ago

armpogart commented 3 years ago

See cycle/orm#116.

This PR ensures that if we annotate child entity with different table than the parent, the child will be built as a separate entity with separate table. The primary key is taken from the parent.

I'm still not sure how to add FK constrain to the child automatically in this case without actually adding annotated @HasOne relation.

For this to fully work we also need a custom mapper for cycle/orm.

codecov[bot] commented 3 years ago

Codecov Report

Merging #13 into master will decrease coverage by 2.54%. The diff coverage is 53.57%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #13      +/-   ##
============================================
- Coverage     88.18%   85.64%   -2.55%     
- Complexity      188      200      +12     
============================================
  Files            14       14              
  Lines           381      404      +23     
============================================
+ Hits            336      346      +10     
- Misses           45       58      +13     
Impacted Files Coverage Δ Complexity Δ
src/Configurator.php 74.56% <28.57%> (-6.82%) 46.00 <19.00> (+6.00) :arrow_down:
src/Entities.php 91.11% <78.57%> (-2.56%) 38.00 <0.00> (+6.00) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7dd29c0...0600777. Read the comment docs.

armpogart commented 3 years ago

As far as building correct annotations to feed schema-builder, everything is ready I guess. I have tested everything manually (the PR doesn't contain any tests for the added functionality, as I had no time to understand how to setup full local testing environment to run all phpunit tests).

I'm still not sure whether the automatic approach (the one done here) is better than introducing additional annotation as it is done in Doctrine. As STI is already there without any additional annotation, I guess this is also ok, if documented.

roxblnfk commented 2 years ago

solved in https://github.com/cycle/annotated/pull/31