many-to-many nullable columns with through#852
Conversation
77fae53 to
4b7de5a
Compare
| is_through_relation_column_nullable = kwargs.pop("is_through_relation_column_nullable", None) | ||
| is_through_reverse_relation_column_nullable = kwargs.pop("is_through_reverse_relation_column_nullable", None) |
There was a problem hiding this comment.
Can you rename it to shorter names: through_relation_nullable and through_reverse_relation_nullable
| ) | ||
| create_and_append_m2m_fk( | ||
| model=model_field.owner, model_field=model_field, field_name=child_name | ||
| model=model_field.owner, model_field=model_field, field_name=child_name, nullable=model_field.is_through_relation_column_nullable, |
There was a problem hiding this comment.
Can you add missing tests for setting that column settings nullable/ not nullable and different expected behavior?
|
Sorry for the long review time! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #852 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 204 204
Lines 14845 14847 +2
=========================================
+ Hits 14845 14847 +2
|
CodSpeed Performance ReportMerging #852 will degrade performances by 12.33%Comparing Summary
Benchmarks breakdown
|
|
Hi @collerek |
…mns (ormar-orm#852) Adds `through_relation_nullable` and `through_reverse_relation_nullable` parameters on `ormar.ManyToMany` so users can enforce NOT NULL on the auto-generated FK columns of the through table. Defaults to True to preserve existing behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ccbd159 to
0f78231
Compare
Use `through_foreign_key_name` / `through_reverse_foreign_key_name` on the test models to override the auto-generated constraint names that otherwise blow past MySQL's identifier length cap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
such code:
cause such migration:
Here
ticker_idandticker_collection_idare nullable by default, and there is no built-in way to set them non nullable.I tried to set
sql_nullableandnullablein arguments oformar.ManyToManybut looks like it affects only typing information.So then I added these two parameters, that will allow to override nullability of both
throughcolumns.