ash-project / ash_postgres

The PostgreSQL data layer for Ash Framework
https://hexdocs.pm/ash_postgres
MIT License
134 stars 73 forks source link

Handle filter condition on create #368

Closed maennchen closed 1 month ago

maennchen commented 1 month ago

I implemented it so that the single create returns the existing row.

Any row that was skipped because of the upsert filter clause will have the metadata entry upsert_skipped set.

Alternatively we could return nil, but I believe that might confuse the users of the function. With bulk creates it makes more sense to be missing.

I couldn't find specific tests for single create / single bulk create. So I added those as well.

This is a prerequisite to implement the syntax sugar from https://github.com/ash-project/ash/issues/1385

Contributor checklist

zachdaniel commented 1 month ago

🚀 Thank you for your contribution! 🚀