Skip to content

Solution#1825

Open
pavliukkk wants to merge 2 commits into
mate-academy:masterfrom
pavliukkk:develop
Open

Solution#1825
pavliukkk wants to merge 2 commits into
mate-academy:masterfrom
pavliukkk:develop

Conversation

@pavliukkk

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor 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.

Review Summary

I am requesting changes because one critical requirement is not fully met: the table_name parameter passed into ActorManager.__init__ is not actually used in your SQL queries, which can break functionality when a different table name is provided. In app/managers.py, every query (SELECT, INSERT, UPDATE, DELETE) still hard-codes the table name actors instead of using self.table_name, so the manager is not truly configurable as intended. This conflicts with the task design and also partially violates the style requirement that the manager should work with a plural table name chosen at construction time ([CHECKLIST ITEM #2]).

To fix this, update all SQL statements in ActorManager to interpolate self.table_name for the table name, for example by building the SQL with an f-string for the table name while still using ? placeholders for values (so only the table name is interpolated, not user data). For instance, your current all query "SELECT id, first_name, last_name FROM actors" should be changed to use self.table_name instead of the literal actors, and similarly for the INSERT, UPDATE, and DELETE statements. Once you do that, your existing logic (including the list comprehension in all that naturally returns an empty list) will satisfy the functional requirements. Your overall structure with the Actor dataclass, correct method signatures, and connection handling is solid, and with these query adjustments your solution will be in good shape.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread app/managers.py
Comment on lines +12 to +13
self.connection = sqlite3.connect(db_name)
self.table_name = table_name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

table_name is accepted as an argument and stored, but all SQL below still uses the hard-coded table name "actors". This makes table_name ineffective; you should build your queries using self.table_name to honor the constructor parameter.

Comment thread app/managers.py Outdated
Comment on lines +16 to +17
cursor = self.connection.execute(
"select * from actors"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This query hard-codes actors instead of using self.table_name. That conflicts with the purpose of passing table_name into __init__ and will break if a different table name is provided.

Comment thread app/managers.py Outdated
Comment on lines +24 to +25
self.connection.execute(
"delete from actors where id = ?", (pk,)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The delete statement also hard-codes actors; update it to use self.table_name so the manager truly works for the table specified in the constructor.

Comment thread app/managers.py Outdated
Comment on lines +30 to +31
self.connection.execute(
"insert into actors (first_name, last_name)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The insert statement should refer to self.table_name instead of the literal actors, otherwise changing the table name in __init__ has no effect.

Comment thread app/managers.py Outdated
Comment on lines +42 to +43
self.connection.execute(
"update actors set first_name = ?, last_name = ?"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly, this update statement should use self.table_name instead of actors to match the dynamic table name passed to the manager.

@mateacademy-ai-mentor mateacademy-ai-mentor 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.

Review Summary

I am approving your solution because it fully meets the functional and structural requirements of the task. You correctly defined the Actor dataclass in models.py with id, first_name, and last_name, and implemented ActorManager in managers.py with the required CRUD methods and signatures. The manager’s __init__ properly accepts db_name and table_name, establishes the SQLite connection, and all SQL statements consistently use self.table_name, matching the configurability requirement and avoiding hard-coded table names. The all() method returns a list of Actor instances and naturally returns an empty list when there are no rows, which aligns with the expected behavior. There are no critical blockers or missing features with respect to the description or checklist, and the default table name being plural ("actors") also follows the naming guidance. Nice work implementing a clean, requirement-compliant solution.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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