keithwhor / nodal

API Services Made Easy With Node.js
http://www.nodaljs.com/
MIT License
4.51k stars 209 forks source link

Schema Field Unique Property Working as Intended? #234

Closed nsipplswezey closed 8 years ago

nsipplswezey commented 8 years ago

An empty or non-unique value sent in a POST request to an endpoint that implements a field that implements the unique property will return an error as expected, but increments the id value of the user table.

Nit pick, and I suspect it's possible this just might be how Postgres doest, but it seems potentially unnecessary.

To reproduce sending a POST request to the user endpoint with a non-unique email.

Specifically

$ nodal new recreate-issue-api
$ cd recreate-issue-api
$ nodal g:model --user
$ nodal db:create
$ nodal db:prepare
$ nodal db:migrate
$ nodal g:controller --for user
$ nodal s

Then POST to the /user/ endpoint twice with

username : test
email : test@test.com
password : password

Then POST again with a unique email

username : test
email : testtest@test.com
password : password

GET to /user/ Screenshot sequence:

screen shot 2016-05-08 at 8 14 58 am screen shot 2016-05-08 at 8 15 01 am screen shot 2016-05-08 at 8 15 07 am screen shot 2016-05-08 at 8 15 15 am

keithwhor commented 8 years ago

Not an error, just the way PG handles sequences.