GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — feat(golang): add emit_read_only_prepared to generate read-only queries by jarri-abidi · Pull Request #4669 · sqlc-dev/sqlc ConversationCloses #3187. Supersedes #3291, which was closed automatically for merge conflicts; this is the same feature rebased onto the current ProblemWith SolutionA new version: "2" sql: - engine: "postgresql" queries: "query.sql" schema: "schema.sql" gen: go: package: "db" out: "db" emit_prepared_queries: true emit_read_only_prepared: true writes, err := db.Prepare(ctx, primary) // every query reads, err := db.PrepareReadOnly(ctx, replica) // read-only queries only user, err := reads.GetUserByID(ctx, id) A query is read-only if it
Changes
Testing
🤖 Generated with Claude Code
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAdd an emit_read_only_prepared option for database/sql. When set, sqlc also generates read.go with a ReadQueries type, created with PrepareReadOnly, that prepares only the read-only queries: those that SELECT and do not INSERT, UPDATE, DELETE or SELECT ... FOR UPDATE. This lets read queries be prepared on a connection whose database user can only read, such as a read replica, without preparing write statements that user isn't allowed to prepare. Prepare is unchanged and keeps every query, and the models are shared, so nothing is duplicated. read.go gets its imports from the read-only queries' own argument and result types, including lib/pq when they bind or scan slices with pq.Array. Keywords are matched when followed by any whitespace, so queries written as "SELECT\n col1, ..." are recognised. pgx is not supported; no read.go is generated for it. Adds the option to the docs and both config schemas, and endtoend fixtures for MySQL, PostgreSQL, and PostgreSQL with slice arguments and results. Closes sqlc-dev#3187. Supersedes sqlc-dev#3291, which was closed for merge conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jarri-abidi
marked this pull request as ready for review
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Option to Segregate Read and Write queries to have separate db users with each type of query.Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |