Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Singularization fails on "aliases" #1571

Closed
leucos opened this issue Feb 5, 2019 · 5 comments
Closed

Singularization fails on "aliases" #1571

leucos opened this issue Feb 5, 2019 · 5 comments
Milestone

Comments

@leucos
Copy link

leucos commented Feb 5, 2019

Description

When creating an API project from scratch with aliases actions and alias resource, parameter ID for Show/Update/Delete is searched under the aliase_id key instead of alias_id.

Inflect package seems fine in this regard (https://github.com/markbates/inflect/blob/master/inflect.go#L237).

Steps to Reproduce the Problem

Generate a new project

buffalo new aliases --api·
cd aliases
buffalo generate resource aliases

Setup database

Fix database.yml and create a postgres user:

create user aliases_development_user password 'aliases_development_pass' CREATEDB;

Then create and migrate database:

buffalo db create
buffalo db migrate

Add a record

$ curl -H'Content-Type:application/json' -XPOST localhost:3000/aliases/ -d '{}'
{"id":"691286e7-09b4-44c7-b0f7-8a929c4540bc","created_at":"2019-02-05T18:52:39.695544

Now retrieve this record

$ curl -HContent-Type:application/json localhost:3000/aliases/691286e7-09b4-44c7-b0f7-8a929c4540bc

On the server, you can see the parameter set un aliase_id instead of \alias_id`:

ERRO[2019-02-05T18:54:40+01:00] pq: invalid input syntax for type uuid: "" content_type=application/json db=1.144636ms duration=6.745362ms human_size="0 B" method=GET params="{\"aliase_id\":[\"691286e7-09b4-44c7-b0f7-8a929c4540bc\"]}" path=/aliases/691286e7-09b4-44c7-b0f7-8a929c4540bc/ request_id=VBMfrmIoYL-jnXyeNrNXq size=0 status=0

Expected Behavior

The parameter should be named alias_id.

Actual Behavior

The parameter should is named aliase_id.

Info

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

### Buffalo Version
v0.13.12

### App Information
Pwd=/home/leucos/dev/perso/tests/buffalo/aliases
Root=/home/leucos/dev/perso/tests/buffalo/aliases
GoPath=/home/leucos/dev/go
Name=aliases
Bin=bin/aliases
PackagePkg=aliases
ActionsPkg=aliases/actions
ModelsPkg=aliases/models
GriftsPkg=aliases/grifts
VCS=git
WithPop=true
WithSQLite=false
WithDep=false
WithWebpack=false
WithYarn=false
WithDocker=true
WithGrifts=true
WithModules=true

### Go Version
go version go1.11 linux/amd64

### Go Env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/leucos/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/leucos/dev/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/leucos/dev/perso/tests/buffalo/aliases/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build173332411=/tmp/go-build -gno-record-gcc-switches"

### Node Version
v8.10.0

### NPM Version
NPM Not Found

### Yarn Version
Yarn Not Found

### PostgreSQL Version
PostgreSQL Not Found

### MySQL Version
mysql  Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using  EditLine wrapper

### SQLite Version
3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1

### Dep Version
could not find a Gopkg.toml file

### Dep Status
could not find a Gopkg.toml file

### go.mod
module aliases

require (
	github.com/codegangsta/negroni v1.0.0 // indirect
	github.com/gobuffalo/buffalo v0.13.12
	github.com/gobuffalo/buffalo-plugins v1.13.0 // indirect
	github.com/gobuffalo/buffalo-pop v1.6.0
	github.com/gobuffalo/envy v1.6.12
	github.com/gobuffalo/mw-contenttype v0.0.0-20180802152300-74f5a47f4d56
	github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
	github.com/gobuffalo/mw-paramlogger v0.0.0-20181005191442-d6ee392ec72e
	github.com/gobuffalo/packr v1.21.9
	github.com/gobuffalo/pop v4.9.5+incompatible
	github.com/gobuffalo/suite v2.6.0+incompatible
	github.com/gobuffalo/uuid v2.0.5+incompatible
	github.com/gobuffalo/validate v2.0.3+incompatible
	github.com/gobuffalo/x v0.0.0-20181110221217-14085ca3e1a9
	github.com/markbates/going v1.0.3 // indirect
	github.com/markbates/grift v1.0.5
	github.com/pkg/errors v0.8.1
	github.com/rs/cors v1.6.0
	github.com/unrolled/secure v0.0.0-20181022170031-4b6b7cf51606
	golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613 // indirect
	golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 // indirect
	golang.org/x/sys v0.0.0-20190204203706-41f3e6584952 // indirect
	golang.org/x/tools v0.0.0-20190205050122-7f7074d5bcfd // indirect
)
@markbates markbates transferred this issue from gobuffalo/buffalo Feb 5, 2019
@leucos
Copy link
Author

leucos commented Feb 5, 2019

Oh ok did not notice it was happening here.
I can send a PR if you wish.

@markbates
Copy link
Member

markbates commented Feb 5, 2019 via email

@leucos
Copy link
Author

leucos commented Feb 5, 2019

Well, spoke to fast. Can't spot it. We already have AddPlural("alias", "aliases") and adding a test in flect_test.go does not make it break.

Note that I use go modules, so may be I am not using this package at all ?

I see the two flect packages in go.sum:

  • github.com/markbates/inflect
  • github.com/gobuffalo/flect/

@markbates markbates transferred this issue from gobuffalo/flect Feb 5, 2019
@markbates
Copy link
Member

I transferred it back, as the issue is in Buffalo. it was using inflect and not flect.

@markbates
Copy link
Member

@leucos PR is here #1572 if you can check it that would be great.

@markbates markbates added this to the v0.14.0 milestone Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants