Skip to content

Commit 93ce9ca

Browse files
authored
Merge pull request #187 from cloudspannerecosystem/revert-allow-commit-timestamp-tmplate
fix: disable automatic CommitTimestamp injection in default template
2 parents cc37c43 + 8294e13 commit 93ce9ca

7 files changed

Lines changed: 82 additions & 26 deletions

File tree

templates/type.go.tpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ func ({{ $short }} *{{ .Name }}) columnsToValues(cols []string) ([]interface{},
7474
{{- range .Fields }}
7575
{{- if not .Col.IsHidden }}
7676
case "{{ colname .Col }}":
77-
{{- if .Col.IsAllowCommitTimestamp }}
78-
ret = append(ret, spanner.CommitTimestamp)
79-
{{- else if .CustomType }}
77+
{{- if .CustomType }}
8078
ret = append(ret, {{ .Type }}({{ $short }}.{{ .Name }}))
8179
{{- else }}
8280
ret = append(ret, {{ $short }}.{{ .Name }})

test/testdata/schema.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ CREATE TABLE GeneratedColumns (
119119

120120
CREATE TABLE AllowCommitTimestamp (
121121
ID INT64 NOT NULL,
122+
EndsAt TIMESTAMP OPTIONS (allow_commit_timestamp=true),
123+
CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true),
122124
UpdatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true)
123125
) PRIMARY KEY(ID);
124126

test/testmodels/customtypes/allowcommittimestamp.yo.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testmodels/default/allowcommittimestamp.yo.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testmodels/single/single_file.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testmodels/underscore/allow_commit_timestamp.yo.go

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tplbin/templates.go

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)