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

Generating a "pepsi" resource doesn't produce the desired outcome #37

Closed
Maidomax opened this issue Feb 19, 2020 · 1 comment · Fixed by #59
Closed

Generating a "pepsi" resource doesn't produce the desired outcome #37

Maidomax opened this issue Feb 19, 2020 · 1 comment · Fixed by #59
Assignees
Labels
bug Something isn't working s: fixed was fixed or solution offered

Comments

@Maidomax
Copy link

Description

When I try to generate a "pepsi" resource in a new buffalo app, the generator sometimes generates the proper names "pepsi/pepsis", and sometimes it generates "pepse/pepses".

METHOD PATH NAME HANDLER
GET / rootPath coke/actions.HomeHandler
GET /pepsis/ pepsisPath coke/actions.PepsisResource.List
POST /pepsis/ pepsisPath coke/actions.PepsisResource.Create
GET /pepsis/new/ newPepsisPath coke/actions.PepsisResource.New
GET /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Show
PUT /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Update
DELETE /pepsis/{pepse_id}/ pepsePath coke/actions.PepsisResource.Destroy
GET /pepsis/{pepse_id}/edit/ editPepsePath coke/actions.PepsisResource.Edit

These inconsistencies are also present in the code of the generated actions, for example:

// List gets all Pepsis. This function is mapped to the path
// GET /pepsis
func (v PepsisResource) List(c buffalo.Context) error {
  // Get the DB connection from the context
  tx, ok := c.Value("tx").(*pop.Connection)
  if !ok {
    return fmt.Errorf("no transaction found")
  }

  pepses := &models.Pepsis{}

Steps to Reproduce the Problem

  1. Generate a new buffalo app with buffalo new dummyapp, and set it up
  2. Inside your new app's folder run buffalo generate resource pepsi
  3. Check the generated code, or start your app in development mode, and try to create a new pepsi entry

Expected Behaviour

"Pepsi" is a weird word, but pluralizing it does make sense, in my opinion, probably as "pepsis", but in any case, I would expect the generator to produce consistent naming and functional codde.

Actual Behaviour

The naming is inconsistent and some routes are broken.

Info

Please run buffalo info and paste the information below where it says "PASTE_HERE".

-> Go: Checking installation
✓ The `go` executable was found on your system at: /snap/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.13.4, meets the minimum requirements.

-> Go: Checking GOPATH
✓ You are using Go Modules, so no need to worry about the GOPATH.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✓ Your PATH contains /home/mladen/go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v13.5.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.13.7, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.21.1, meets the minimum requirements.

-> PostgreSQL: Checking installation
✘ The `postgres` executable could not be found on your system.
For help setting up your Postgres environment please follow the instructions for you platform at:

https://www.postgresql.org/download/

-> MySQL: Checking installation
✓ The `mysql` executable was found on your system at: /usr/bin/mysql

-> MySQL: Checking minimum version requirements
✓ Your version of MySQL, 14.14, meets the minimum requirements.

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.22.0, meets the minimum requirements.

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /usr/local/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.15.3, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/mladen/Projects/BuffaloTest/coke
Root        /home/mladen/Projects/BuffaloTest/coke
GoPath      /home/mladen/go
PackagePkg  coke
ActionsPkg  coke/actions
ModelsPkg   coke/models
GriftsPkg   coke/grifts
WithModules true
Name        coke
Bin         bin/coke
VCS         git
WithPop     true
WithSQLite  false
WithDep     false
WithWebpack true
WithNodeJs  true
WithYarn    true
WithDocker  true
WithGrifts  true
AsWeb       true
AsAPI       false
InApp       true
PackageJSON {map[build:webpack -p --progress dev:webpack --watch]}

-> Buffalo: config/buffalo-app.toml
name = "coke"
bin = "bin/coke"
vcs = "git"
with_pop = true
with_sqlite = false
with_dep = false
with_webpack = true
with_nodejs = true
with_yarn = true
with_docker = true
with_grifts = true
as_web = true
as_api = false

-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop"

-> Buffalo: go.mod
module coke

go 1.13

require (
	github.com/gobuffalo/buffalo v0.15.3
	github.com/gobuffalo/buffalo-pop v1.23.1
	github.com/gobuffalo/envy v1.8.1
	github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517
	github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
	github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4
	github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
	github.com/gobuffalo/packr/v2 v2.7.1
	github.com/gobuffalo/pop v4.13.1+incompatible
	github.com/gobuffalo/suite v2.8.2+incompatible
	github.com/gobuffalo/validate v2.0.3+incompatible
	github.com/gofrs/uuid v3.2.0+incompatible
	github.com/markbates/grift v1.5.0
	github.com/stretchr/testify v1.4.0
	github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

@sio4
Copy link
Member

sio4 commented Sep 3, 2022

Confirmed. The issue was caused by the suffix rule of {"pse", "psis"}, but not sure which (and how many) words are under this rule.

Other words not working fine with the current suffix rule:

I think removing the rule is better since I could not find an example of "~pse" -> "~psis" but many examples of "~es".

Will remove the rule with a comment.

@sio4 sio4 self-assigned this Sep 3, 2022
@sio4 sio4 added bug Something isn't working s: accepted was accepted or confirmed labels Sep 3, 2022
sio4 added a commit that referenced this issue Sep 3, 2022
@sio4 sio4 closed this as completed in 4d28a21 Sep 3, 2022
@sio4 sio4 added s: fixed was fixed or solution offered and removed s: accepted was accepted or confirmed labels Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working s: fixed was fixed or solution offered
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants