Make statements classes implementing a contract#2
Open
nikita-volkov wants to merge 3 commits into
Open
Conversation
Following the pattern from other generators and providing for polymorphic observability among other potential features.
There was a problem hiding this comment.
Pull request overview
This PR refactors the generated SQL statement APIs from free functions into dataclass-based statement objects that implement a shared Statement protocol, enabling a uniform interface (and supporting cross-cutting concerns like observability via the exposed SQL).
Changes:
- Introduces a
_generated._core.Statementprotocol and updates generated statement modules to exposeStatement-implementing dataclasses withexecute/execute_sync. - Updates
music_catalogue.__init__exports to surface the new statement classes (instead of the prior function-based API). - Removes the previously-exported sync wrapper functions from
music_catalogue.sync.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/music_catalogue/sync/init.py | Removes sync wrapper exports; currently leaves the sync surface without statement entrypoints (see PR comments). |
| src/music_catalogue/_generated/_core.py | Adds the Statement[R] protocol contract shared by statement implementations. |
| src/music_catalogue/_generated/statements/insert_album.py | Converts insert_album functions into InsertAlbum(Statement[InsertAlbumRow]). |
| src/music_catalogue/_generated/statements/insert_multiple_albums.py | Converts insert_multiple_albums functions into InsertMultipleAlbums(Statement[list[...]] ). |
| src/music_catalogue/_generated/statements/select_album_by_format.py | Converts select_album_by_format functions into SelectAlbumByFormat statement class. |
| src/music_catalogue/_generated/statements/select_album_by_id.py | Converts select_album_by_id functions into SelectAlbumById statement class. |
| src/music_catalogue/_generated/statements/select_album_by_name.py | Converts select_album_by_name functions into SelectAlbumByName statement class. |
| src/music_catalogue/_generated/statements/select_album_with_filters.py | Converts select_album_with_filters functions into SelectAlbumWithFilters statement class. |
| src/music_catalogue/_generated/statements/select_album_with_tracks.py | Converts select_album_with_tracks functions into SelectAlbumWithTracks statement class. |
| src/music_catalogue/_generated/statements/select_genre_by_artist.py | Converts select_genre_by_artist functions into SelectGenreByArtist statement class. |
| src/music_catalogue/_generated/statements/update_album_recording_returning.py | Converts update_album_recording_returning functions into UpdateAlbumRecordingReturning statement class. |
| src/music_catalogue/_generated/statements/update_album_released.py | Converts update_album_released functions into UpdateAlbumReleased(Statement[int]). |
| src/music_catalogue/init.py | Re-exports Statement and the new statement classes as the primary public API. |
| .gitignore | Adds *.pyc to ignore list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Following the pattern from other generators and providing for polymorphic observability among other potential features.