Skip to content

Commit

Permalink
fix: update type of ListQuery.Limit to int32
Browse files Browse the repository at this point in the history
To match the type (int32) of the AIP page size standard field.
  • Loading branch information
odsod committed Jan 15, 2021
1 parent 09dbd5f commit 8f46165
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion internal/codegen/databasecodegen/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (g CommonCodeGenerator) generateListQueryStruct(f *codegen.File) {
f.P("type ", g.ListQueryType(), " struct {")
f.P("Where ", spansqlPkg, ".BoolExpr")
f.P("Order []", spansqlPkg, ".Order")
f.P("Limit int64")
f.P("Limit int32")
f.P("Offset int64")
f.P("}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (g InterleavedReadTransactionCodeGenerator) generateListRowsMethod(f *codeg
f.P("stmt := ", spannerPkg, ".Statement{")
f.P("SQL: q.String(),")
f.P("Params: map[string]interface{}{")
f.P(strconv.Quote(limitParam), ": query.Limit,")
f.P(strconv.Quote(limitParam), ": int64(query.Limit),")
f.P(strconv.Quote(offsetParam), ": query.Offset,")
f.P("},")
f.P("}")
Expand Down Expand Up @@ -181,7 +181,7 @@ func (g InterleavedReadTransactionCodeGenerator) generateBatchGetRowsMethod(f *c
f.P("foundRows := make(map[", primaryKey.Type(), "]*", interleavedRow.Type(), ", len(keys))")
f.P("if err := t.List(ctx, ", common.ListQueryType(), "{")
f.P("Where: ", spansqlPkg, ".Paren{Expr: where},")
f.P("Limit: int64(len(keys)),")
f.P("Limit: int32(len(keys)),")
f.P("}).Do(func(row *", interleavedRow.Type(), ") error {")
f.P("foundRows[row.", interleavedRow.KeyMethod(), "()] = row")
f.P("return nil")
Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/databasecodegen/readtransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (g ReadTransactionCodeGenerator) generateListRowsMethod(f *codegen.File) {
f.P("Offset: ", spansqlPkg, ".Param(", strconv.Quote(offsetParam), "),")
f.P("}.SQL(),")
f.P("Params: map[string]interface{}{")
f.P(strconv.Quote(limitParam), ": query.Limit,")
f.P(strconv.Quote(limitParam), ": int64(query.Limit),")
f.P(strconv.Quote(offsetParam), ": query.Offset,")
f.P("},")
f.P("}")
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/databasecodegen/testdata/1.sql.database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions internal/codegen/databasecodegen/testdata/2.sql.database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions internal/examples/freightdb/database_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions internal/examples/musicdb/database_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8f46165

Please sign in to comment.