Skip to content

Apply PR #110's Read index doc comment fix to v1 templates#205

Open
TakumaKurosawa wants to merge 1 commit into
cloudspannerecosystem:masterfrom
TakumaKurosawa:fix-read-index-comment-v1
Open

Apply PR #110's Read index doc comment fix to v1 templates#205
TakumaKurosawa wants to merge 1 commit into
cloudspannerecosystem:masterfrom
TakumaKurosawa:fix-read-index-comment-v1

Conversation

@TakumaKurosawa
Copy link
Copy Markdown

Summary

The v1 templates/index.go.tpl hardcodes the doc comment on every generated Read{{ .FuncName }} as // Generated from unique index '...'., even when the underlying index is not unique. As a result, downstream users of the v1 generator see misleading doc comments on non-unique-index ReadXxx functions.

This is the same issue that was fixed for the v2 templates in #110 (merged 2022-12-07). That fix has not been backported to the v1 templates, and the v1 series is still being actively released (v0.8.0 and v0.8.1 in January 2026), so it remains worth fixing for v1 users.

Change

Mirror #110 exactly — drop the word unique from the Read{{ .FuncName }} doc comment so it reads // Generated from index '...'. regardless of uniqueness:

-// Generated from unique index '{{ .Index.IndexName }}'.
+// Generated from index '{{ .Index.IndexName }}'.
 func Read{{ .FuncName }}(ctx context.Context, db YORODB, keys spanner.KeySet) ([]*{{ .Type.Name }}, error) {

tplbin/templates.go and test/testmodels/**/*.yo.go are regenerated via make regen and make testdata-from-ddl to reflect the template change.

Scope

  • Comment-only change. No runtime behavior change.
  • Touches only the v1 paths: templates/index.go.tpl, tplbin/templates.go, and regenerated test/testmodels/**/*.yo.go.
  • The v2/ tree is untouched (already fixed by Fix typo in index.go.tpl #110).

Test plan

  • make regen (rebuild embedded templates)
  • go build
  • make testdata-from-ddl (regenerate v1 test models from DDL)
  • go vet ./... clean
  • gofmt -l clean
  • make test was not run locally because it requires a running Spanner emulator and the diff is comment-only with no runtime behavior change. Happy to run it via the Spanner emulator if a reviewer would like to confirm.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 26, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@TakumaKurosawa
Copy link
Copy Markdown
Author

@googlebot I signed it!

…templates

PR cloudspannerecosystem#110 fixed the misleading "Generated from unique index" comment on
ReadXxx for the v2 templates. The same issue still exists in the v1
templates/index.go.tpl. Apply the same one-word change so users of
the v1 codegen also get accurate doc comments.
@TakumaKurosawa TakumaKurosawa force-pushed the fix-read-index-comment-v1 branch from b4bc7e7 to ca14be3 Compare May 26, 2026 02:41
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.

1 participant