Skip to content

Make statements classes implementing a contract#2

Open
nikita-volkov wants to merge 3 commits into
mainfrom
statement-class
Open

Make statements classes implementing a contract#2
nikita-volkov wants to merge 3 commits into
mainfrom
statement-class

Conversation

@nikita-volkov

Copy link
Copy Markdown
Contributor

Following the pattern from other generators and providing for polymorphic observability among other potential features.

Following the pattern from other generators and providing for polymorphic observability among other potential features.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Statement protocol and updates generated statement modules to expose Statement-implementing dataclasses with execute / 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.

Comment thread src/music_catalogue/sync/__init__.py
Comment thread src/music_catalogue/sync/__init__.py
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.

3 participants