Skip to content
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

examples: Add missing Close calls #3828

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Feb 7, 2025

The PR fixes sqltest.SQLite usages and implementation by adding the missing sdb.Close() and source.Close().

sqltest.SQLite returns *sql.DB, which we need to close as shown here:

db, cleanup := sqltest.CreateSQLiteDatabase(t, dsn, []string{s})
defer db.Close()
defer cleanup()

os.CreateTemp creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting file. We also need to close it.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 7, 2025
@alexandear alexandear force-pushed the fix-add-missing-close branch from 6608af4 to 36b91d9 Compare February 7, 2025 14:23
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Feb 7, 2025
@kyleconroy kyleconroy merged commit 6dacff2 into sqlc-dev:main Feb 7, 2025
8 checks passed
@kyleconroy
Copy link
Collaborator

Thanks!

@alexandear alexandear deleted the fix-add-missing-close branch February 7, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants