Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect generate model names for "metadata" suffix #3553

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading