Skip to content

Commit 58674b4

Browse files
authored
Fix incorrect generate model names for "metadata" suffix (#3553)
1 parent 7d66890 commit 58674b4

File tree

21 files changed

+174
-5
lines changed

21 files changed

+174
-5
lines changed

internal/endtoend/testdata/inflection/mysql/go/models.go

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

internal/endtoend/testdata/inflection/mysql/go/query.sql.go

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

internal/endtoend/testdata/inflection/mysql/query.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ SELECT * FROM product_meta;
99

1010
/* name: ListCalories :many */
1111
SELECT * FROM calories;
12+
13+
/* name: GetProductMetadata :many */
14+
SELECT * FROM product_metadata;

internal/endtoend/testdata/inflection/mysql/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
22
CREATE TABLE students (id text not null);
33
CREATE TABLE product_meta (id text not null);
44
CREATE TABLE calories (id text not null);
5-
5+
CREATE TABLE product_metadata (id text not null);

internal/endtoend/testdata/inflection/postgresql/pgx/v4/go/models.go

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

internal/endtoend/testdata/inflection/postgresql/pgx/v4/go/query.sql.go

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

internal/endtoend/testdata/inflection/postgresql/pgx/v4/query.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ SELECT * FROM product_meta;
99

1010
-- name: ListCalories :many
1111
SELECT * FROM calories;
12+
13+
-- name: GetProductMetadata :many
14+
SELECT * FROM product_metadata;

internal/endtoend/testdata/inflection/postgresql/pgx/v4/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
22
CREATE TABLE students (id text not null);
33
CREATE TABLE product_meta (id text not null);
44
CREATE TABLE calories (id text not null);
5-
5+
CREATE TABLE product_metadata (id text not null);

internal/endtoend/testdata/inflection/postgresql/pgx/v5/go/models.go

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

internal/endtoend/testdata/inflection/postgresql/pgx/v5/go/query.sql.go

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

internal/endtoend/testdata/inflection/postgresql/pgx/v5/query.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ SELECT * FROM product_meta;
99

1010
-- name: ListCalories :many
1111
SELECT * FROM calories;
12+
13+
-- name: GetProductMetadata :many
14+
SELECT * FROM product_metadata;

internal/endtoend/testdata/inflection/postgresql/pgx/v5/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
22
CREATE TABLE students (id text not null);
33
CREATE TABLE product_meta (id text not null);
44
CREATE TABLE calories (id text not null);
5-
5+
CREATE TABLE product_metadata (id text not null);

internal/endtoend/testdata/inflection/postgresql/stdlib/go/models.go

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

internal/endtoend/testdata/inflection/postgresql/stdlib/go/query.sql.go

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

internal/endtoend/testdata/inflection/postgresql/stdlib/query.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ SELECT * FROM product_meta;
99

1010
-- name: ListCalories :many
1111
SELECT * FROM calories;
12+
13+
-- name: GetProductMetadata :many
14+
SELECT * FROM product_metadata;

internal/endtoend/testdata/inflection/postgresql/stdlib/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
22
CREATE TABLE students (id text not null);
33
CREATE TABLE product_meta (id text not null);
44
CREATE TABLE calories (id text not null);
5-
5+
CREATE TABLE product_metadata (id text not null);

internal/endtoend/testdata/inflection/sqlite/go/models.go

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

internal/endtoend/testdata/inflection/sqlite/go/query.sql.go

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

internal/endtoend/testdata/inflection/sqlite/query.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ SELECT * FROM product_meta;
99

1010
/* name: ListCalories :many */
1111
SELECT * FROM calories;
12+
13+
/* name: GetProductMetadata :many */
14+
SELECT * FROM product_metadata;

internal/endtoend/testdata/inflection/sqlite/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE campus (id text not null);
22
CREATE TABLE students (id text not null);
33
CREATE TABLE product_meta (id text not null);
44
CREATE TABLE calories (id text not null);
5-
5+
CREATE TABLE product_metadata (id text not null);

internal/inflection/singular.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@ func Singular(s SingularParams) string {
4343
if strings.ToLower(s.Name) == "waves" {
4444
return "wave"
4545
}
46+
47+
if strings.ToLower(s.Name) == "metadata" {
48+
return "metadata"
49+
}
50+
4651
return upstream.Singular(s.Name)
4752
}

0 commit comments

Comments
 (0)