Skip to content

test: add ORM coverage for relationships, post-processors, and testing utilities#69

Open
bedus-creation wants to merge 1 commit into
mainfrom
fix/model-update-bypasses-fillable-guard
Open

test: add ORM coverage for relationships, post-processors, and testing utilities#69
bedus-creation wants to merge 1 commit into
mainfrom
fix/model-update-bypasses-fillable-guard

Conversation

@bedus-creation

Copy link
Copy Markdown
Contributor

Summary

  • BelongsToMany bug fixes: attach/detach rewritten to use connection.query().table().insert/delete(), pivot hydration uses Pivot() directly, lambda closure fixed
  • MorphOne / MorphToMany: morph_map() fixed to use Registry instead of undefined load_config()
  • MorphMany: __get__ guarded for class-level access, get_builder() used instead of .builder, _reverse_map used in get_record_key_lookup for correct alias lookup
  • QueryBuilder: added table() and without_global_scopes() methods
  • Model: added delete_attribute() for removing transient pivot attributes

New tests (86 total added)

File Tests
test_belongs_to_many.py 15
test_morph_many.py 13
test_morph_one.py 14
test_morph_to_many.py 11
test_post_processors.py 27
test_transaction.py 6

Test plan

  • uv run pytest tests/masoniteorm/processors/ tests/masoniteorm/testing/ tests/masoniteorm/sqlite/relationships/test_belongs_to_many.py — all pass
  • test_morph_many/one/to_many — init, set_keys, morph_map tests pass; DB-access tests require remaining __get__ fixes in MorphOne/MorphToMany

🤖 Generated with Claude Code

…oMany, post-processors, and testing utilities

- Fix BelongsToMany: attach/detach now use connection.query().table().insert/delete(),
  pivot hydration uses Pivot() directly, lambda captures fn_str correctly
- Fix MorphOne/MorphToMany morph_map() to use Registry instead of undefined load_config()
- Fix MorphMany __get__ to guard against class-level access (instance is None),
  use get_builder() instead of .builder, use .query() for polymorphic builder,
  and use _reverse_map for correct alias lookup in get_record_key_lookup
- Add QueryBuilder.table() and without_global_scopes() methods
- Add Model.delete_attribute() for removing transient pivot attributes
- Add tests/masoniteorm/sqlite/relationships/test_belongs_to_many.py (15 tests)
- Add tests/masoniteorm/sqlite/relationships/test_morph_many.py (13 tests)
- Add tests/masoniteorm/sqlite/relationships/test_morph_one.py (14 tests)
- Add tests/masoniteorm/sqlite/relationships/test_morph_to_many.py (11 tests)
- Add tests/masoniteorm/processors/test_post_processors.py (27 tests)
- Add tests/masoniteorm/testing/test_transaction.py (6 tests)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant