keithwhor / nodal

API Services Made Easy With Node.js

Home Page:http://www.nodaljs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Schema Field Unique Property Working as Intended?

nsipplswezey opened this issue · comments

commented

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

Not an error, just the way PG handles sequences.