Skip to content

Fix: Incorrect SQL statement in update_days_attended of mod.rs #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

he1senbrg
Copy link
Contributor

@he1senbrg he1senbrg commented Mar 4, 2025

There is issue with the numbering of placeholders in the update_days_attended function.

The UPDATE statement had:

UPDATE AttendanceSummary
SET days_attended = days_attended + 1
WHERE member_id = $2
AND year = $3
AND month = $4

This was wrong because the placeholders didn’t match the parameters being passed. The correct order should be:

UPDATE AttendanceSummary
SET days_attended = days_attended + 1
WHERE member_id = $1
AND year = $2
AND month = $3

Similarly, the below INSERT statement didn't have the placeholder $3 specified for month.

sqlx::query(
                r#"
                    INSERT INTO AttendanceSummary (member_id, year, month, days_attended)
                    VALUES ($1, $2, $3, 1)
                "#,
            )
            .bind(member_id)
            .bind(year)
            .bind(month)
            .execute(pool)
            .await
            .unwrap();

@he1senbrg he1senbrg changed the base branch from main to develop March 4, 2025 18:22
@ivinjabraham
Copy link
Member

Crazy how this stayed unnoticed for so long. Good catch, though I would prefer having a description of the fix and/or bug in the commit message so it's easier to review later.

@he1senbrg
Copy link
Contributor Author

@ivinjabraham I have added the description.

@ivinjabraham
Copy link
Member

Heh, I meant in the commit message since that's what we'll be looking at in the future. But don't sweat it, I'll merge this in a while. Just making a few other changes in the meantime.

@he1senbrg
Copy link
Contributor Author

oops, I'll make sure to word commits better next time.

@ivinjabraham ivinjabraham merged commit 6a48854 into amfoss:develop Mar 4, 2025
2 checks passed
@he1senbrg he1senbrg deleted the summary branch April 21, 2025 05:54
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.

2 participants