vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
218 stars 116 forks source link

Explicitly set all columns when creating arrays of models #595

Closed gwynne closed 9 months ago

gwynne commented 9 months ago

These changes are now available in 1.47.1

When performing an insert query (the "create" model action), we now explicitly emit DEFAULT as the value for fields which have not been set. This ensures that when creating an array of models, the column count for each individual model is the same even if not all fields are set on each one, avoiding a fatal error.

Fixes #594.

codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (3ae5187) 47.32% compared to head (1c1508f) 47.39%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #595 +/- ## ========================================== + Coverage 47.32% 47.39% +0.06% ========================================== Files 106 106 Lines 4754 4756 +2 ========================================== + Hits 2250 2254 +4 + Misses 2504 2502 -2 ``` | [Files](https://app.codecov.io/gh/vapor/fluent-kit/pull/595?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/FluentKit/Model/Fields.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/595?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvTW9kZWwvRmllbGRzLnN3aWZ0) | `97.43% <100.00%> (+0.13%)` | :arrow_up: | | [Sources/FluentKit/Model/Model+CRUD.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/595?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvTW9kZWwvTW9kZWwrQ1JVRC5zd2lmdA==) | `81.50% <100.00%> (ø)` | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/vapor/fluent-kit/pull/595/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor)