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

Resource Named Param and Routes change after upgrade #44

Closed
miticotoby opened this issue Apr 29, 2020 · 1 comment · Fixed by #50
Closed

Resource Named Param and Routes change after upgrade #44

miticotoby opened this issue Apr 29, 2020 · 1 comment · Fixed by #50

Comments

@miticotoby
Copy link

Description

Resource Named Routes and Named Parameters change after upgrade from 0.14 to 0.16.8. also reproducible on brand new app generated from scratch
probably matches a list of reserved names but it would nice to know that list

on new initialized app it's not really a problem but on existing app (I have a nested resource under Devices)

  1. it needs a lot of refactoring and
  2. pop "BelongsTo" call seems to ignore the customized "fk_id" tag. and looks for "devex_id" instead of "device_id" for the nested resource, I guess that would be more a bug for pop than buffalo. the only work around is either hardcode a where query or a Eager query.

here a very plain simple out-of-the-box simulation showing/reproducing the problem, I'm happy to post more in comments later to avoid confusion

Steps to Reproduce the Problem

  1. create new app buffalo new whatever --db-type sqlite3
  2. create resource devices buffalo g resource devices
  3. migrations buffalo pop migrate up
  4. check routes: buffalo routes

Expected Behavior

METHOD | PATH                      | ALIASES | NAME           | HANDLER
------ | ----                      | ------- | ----           | -------
GET    | /                         |         | rootPath       | whatever/actions.HomeHandler
GET    | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.List
POST   | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.Create
GET    | /devices/new/             |         | newDevicesPath | whatever/actions.DevicesResource.New
GET    | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Show
PUT    | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Update
DELETE | /devices/{device_id}/      |         | devicePath      | whatever/actions.DevicesResource.Destroy
GET    | /devices/{device_id}/edit/ |         | editDevicePath  | whatever/actions.DevicesResource.Edit

Actual Behavior

METHOD | PATH                      | ALIASES | NAME           | HANDLER
------ | ----                      | ------- | ----           | -------
GET    | /                         |         | rootPath       | whatever/actions.HomeHandler
GET    | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.List
POST   | /devices/                 |         | devicesPath    | whatever/actions.DevicesResource.Create
GET    | /devices/new/             |         | newDevicesPath | whatever/actions.DevicesResource.New
GET    | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Show
PUT    | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Update
DELETE | /devices/{devex_id}/      |         | devexPath      | whatever/actions.DevicesResource.Destroy
GET    | /devices/{devex_id}/edit/ |         | editDevexPath  | whatever/actions.DevicesResource.Edit

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: /home/toby/bin/go

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

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

-> Go: Checking PATH
✘ Your PATH (/home/mitico/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin) does not contain /home/toby/go/bin.

Without /home/mitico/go/bin in your `PATH` any Go executables can not be run globally.

For help setting up your Go environment please follow the instructions for you platform at:

https://www.gopherguides.com/courses/preparing-your-environment-for-go-development

-> Node: Checking installation
✓ The `node` executable was found on your system at: /home/mitico/bin/node

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

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /home/mitico/bin/npm

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

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /home/mitico/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.22.4, 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 could not be found on your system.
For help setting up your MySQL environment please follow the instructions for you platform at:

https://www.mysql.com/downloads/

-> 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.29.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: /home/toby/bin/buffalo

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

-> Buffalo: Application Details
Pwd         /home/mitico/whatever
Root        /home/mitico/whatever
GoPath      /home/mitico/go
PackagePkg  whatever
ActionsPkg  whatever/actions
ModelsPkg   whatever/models
GriftsPkg   whatever/grifts
WithModules true
Name        whatever
Bin         bin/whatever
VCS         git
WithPop     true
WithSQLite  true
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 = "whatever"
bin = "bin/whatever"
vcs = "git"
with_pop = true
with_sqlite = true
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/v2"
  tags = ["sqlite"]

-> Buffalo: go.mod
module whatever

go 1.14

require (
        github.com/gobuffalo/buffalo v0.15.5
        github.com/gobuffalo/buffalo-pop/v2 v2.0.6
        github.com/gobuffalo/envy v1.9.0
        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.8.0
        github.com/gobuffalo/pop/v5 v5.1.1
        github.com/gobuffalo/validate/v3 v3.1.0
        github.com/gobuffalo/x v0.0.0-20190224155809-6bb134105960
        github.com/gofrs/uuid v3.2.0+incompatible
        github.com/markbates/grift v1.5.0
        github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

@paganotoni
Copy link
Member

Hi @miticotoby thanks for reporting this one. This seems to be related with gobuffalo/flect. I think the affecting rule is:

https://github.com/gobuffalo/flect/blob/master/plural_rules.go#L250

I'm transferring this issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants