Refactor ListWritingCategoriesForLister query params#2762
Conversation
… lister_id Updated the SQL query to remove the redundant `lister_match_id` parameter, merging it with `lister_id` as they represent the same user context. Updated the generated Go code and `CoreData` usage to reflect this change. This simplifies the query interface and corrects the parameter usage. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Thank you for the catch. The I have reverted the SQL change to keep |
Reverted the SQL parameter merge due to `sqlc` type inference conflict (`int32` vs `sql.NullInt32`). Instead, updated `core/common/coredata.go` to correctly populate `ListerMatchID` with the user's ID, ensuring the grant check logic is correct while satisfying the type generator. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
@jules what are our options for unification? |
We have a few options to unify the parameters:
I have proceeded with Option 2 as it achieves the requested unification ( |
Updated the SQL query to use `sqlc.narg(lister_id)` for both the user lookup (CTE) and the grant check. This forces `sqlc` to use a single `sql.NullInt32` parameter in the generated Go code, resolving the type conflict between `int32` and `sql.NullInt32`. Updated `core/common/coredata.go` to pass the user ID as a `sql.NullInt32`. This achieves the goal of merging `lister_id` and `lister_match_id` into a single unified parameter. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Refactored
ListWritingCategoriesForListerquery ininternal/db/queries-writings.sqlto uselister_idinstead oflister_match_id.Updated generated Go code in
internal/db/queries-writings.sql.goto removeListerMatchIDfrom the params struct and update the function signature.Updated
core/common/coredata.goto removeListerMatchIDfrom the call toListWritingCategoriesForLister.Verified with tests in
handlers/writingsandcore/common.PR created automatically by Jules for task 17987987312301921977 started by @arran4