rethinkdb / horizon

Horizon is a realtime, open-source backend for JavaScript apps.
MIT License
6.78k stars 349 forks source link

Bug - ID validation #859

Closed joejordanbrown closed 7 years ago

joejordanbrown commented 8 years ago

Client version:

Latest

When an object is inserted using insert, store and upsert with an empty id shouldn't it generate a UUID?

Example:

let json = {
  id: "",
  test: "data"
};

horizon('testing').store(json)...

should return

horizon('testing').fetch()...
{
  id: "1796f55c-7e9c-43bd-a7ed-38404adfeb2a",
  test: "data"
}

not

horizon('testing').fetch()...
{
  id: "",
  test: "data"
}

That's how you'd expect it to work right?

marshall007 commented 7 years ago

"" is considered a valid primary key value in RethinkDB (as is any string, bool, or number). I don't really think it makes sense to make any special case exceptions on the client to the constraints RethinkDB already imposes.

The server will generate a UUID for the document when no id field is provided by the client.