jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

Jelly_Field_Primary should be "unique" #82

Closed glamorous closed 14 years ago

glamorous commented 14 years ago

Don't know if it's necessary for the code but a primary key should always be unique. Now it's default set to FALSE what's incorrect.

jonathangeiger commented 14 years ago

The unique validation callback introduces a lot of overhead though, because it must query the database to see if the primary key already exists. Generally the uniqueness of primary keys is managed by the database auto-incrementing on INSERT.

If your primary keys are strings or something that the database can't auto-increment, then setting unique to TRUE makes sense. However, since this is not the norm, FALSE is what the default is.

glamorous commented 14 years ago

Ok thanks, that's a good explanation. I didn't knew that this was used to do some extra query-work. :)