Repository navigation
test: assert sqlmodel_update fluent identity and Session.exec non-scalar queries - #2126
Closed
janmejai2002 wants to merge 1 commit into
Closed
janmejai2002 wants to merge 1 commit into
janmejai2002 wants to merge 1 commit into
Conversation
Member
|
@janmejai2002, please stop ignoring contribution guidelines and PR template (I already warned you here). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR improves unit test coverage and assertions for two core SQLModel APIs:
sqlmodel_update()method contracts:tests/test_update.pypreviously invokedorg.sqlmodel_update(...)without asserting the updated field values or verifying that the method returnsself.sqlmodel_update()updates model attributes, preserves unmodified fields, and adheres to the fluent return contract (assert result is org).sqlmodel_update({"name": ...})), ensuring non-model keys in dictionaries or updates are safely ignored without polluting attributes.ValueErroris raised when unsupported types (non-dict, non-BaseModel) are passed tosqlmodel_update().Session.exec()non-scalar queries and bulk updates:Session.exec()distinguishes betweenSelectOfScalar(which unwraps scalars) and standardSelect/UpdateBasequeries (which return tuples orCursorResult).tests/test_query.pypreviously only covered single-model scalar selects (select(Hero)).session.exec(select(Hero.id, Hero.name))properly returns row tuples ((hero.id, "Deadpond")).session.exec(update(Hero)...)returns a validCursorResultwith expected.rowcount == 1.Verification
pytest tests/test_update.py tests/test_query.py -v: 7 passed in 0.12s.ruff checkandruff format --check: all checks passed, 0 errors.