Skip to content

Commit

Permalink
Fix incorrect generate model names for "metadata" suffix (#3553)
Browse files Browse the repository at this point in the history
  • Loading branch information
qanghaa authored Nov 25, 2024
1 parent 7d66890 commit 58674b4
Show file tree
Hide file tree
Showing 21 changed files with 174 additions and 5 deletions.
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/inflection/mysql/go/models.go

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

27 changes: 27 additions & 0 deletions internal/endtoend/testdata/inflection/mysql/go/query.sql.go

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

3 changes: 3 additions & 0 deletions internal/endtoend/testdata/inflection/mysql/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ SELECT * FROM product_meta;

/* name: ListCalories :many */
SELECT * FROM calories;

/* name: GetProductMetadata :many */
SELECT * FROM product_metadata;
2 changes: 1 addition & 1 deletion internal/endtoend/testdata/inflection/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
CREATE TABLE students (id text not null);
CREATE TABLE product_meta (id text not null);
CREATE TABLE calories (id text not null);

CREATE TABLE product_metadata (id text not null);

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ SELECT * FROM product_meta;

-- name: ListCalories :many
SELECT * FROM calories;

-- name: GetProductMetadata :many
SELECT * FROM product_metadata;
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
CREATE TABLE students (id text not null);
CREATE TABLE product_meta (id text not null);
CREATE TABLE calories (id text not null);

CREATE TABLE product_metadata (id text not null);

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ SELECT * FROM product_meta;

-- name: ListCalories :many
SELECT * FROM calories;

-- name: GetProductMetadata :many
SELECT * FROM product_metadata;
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
CREATE TABLE students (id text not null);
CREATE TABLE product_meta (id text not null);
CREATE TABLE calories (id text not null);

CREATE TABLE product_metadata (id text not null);

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ SELECT * FROM product_meta;

-- name: ListCalories :many
SELECT * FROM calories;

-- name: GetProductMetadata :many
SELECT * FROM product_metadata;
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
CREATE TABLE students (id text not null);
CREATE TABLE product_meta (id text not null);
CREATE TABLE calories (id text not null);

CREATE TABLE product_metadata (id text not null);
4 changes: 4 additions & 0 deletions internal/endtoend/testdata/inflection/sqlite/go/models.go

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

27 changes: 27 additions & 0 deletions internal/endtoend/testdata/inflection/sqlite/go/query.sql.go

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

3 changes: 3 additions & 0 deletions internal/endtoend/testdata/inflection/sqlite/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ SELECT * FROM product_meta;

/* name: ListCalories :many */
SELECT * FROM calories;

/* name: GetProductMetadata :many */
SELECT * FROM product_metadata;
2 changes: 1 addition & 1 deletion internal/endtoend/testdata/inflection/sqlite/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
CREATE TABLE students (id text not null);
CREATE TABLE product_meta (id text not null);
CREATE TABLE calories (id text not null);

CREATE TABLE product_metadata (id text not null);
5 changes: 5 additions & 0 deletions internal/inflection/singular.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ func Singular(s SingularParams) string {
if strings.ToLower(s.Name) == "waves" {
return "wave"
}

if strings.ToLower(s.Name) == "metadata" {
return "metadata"
}

return upstream.Singular(s.Name)
}

0 comments on commit 58674b4

Please sign in to comment.