https://github.com/ChicagoBoss/boss_db/issues/135
The problem is that delete(Something) is used for both regular
records, like "student-132", as well as counters, where it could be
any key.
I think this has some problems, but am not entirely sure what the best
solution is.
1. If you happen to have a counter named "student-1234", it'll get
deleted as well as the record you were trying to eliminate.
2. Since the delete() code tries to infer a type from the string it's
given, it'll crash if it does *not* get something that it can infer a
table name from!
3. I was looking through the various adapters. It looks like mongodb
doesn't even implement the deletion from counters.
Some ideas about what to do:
* Separate counter key deletion from record deletion. This is the
clean thing to do. It breaks backwards compatibility. But honestly,
given #2 above, I'm not sure anyone can have used this successfully
anyway.
* Catch the results from this: {_, TableName, IdColumn, TableId} =
boss_sql_lib:infer_type_from_id(Id) - if it fetches a valid table,
then delete the record; if not, delete the counter key. This means
you can't use keys like 'foo-1234' in your counter.
I think I'd do the clean thing and create a delete_counter function.
Any objections?
--
David N. Welton
http://www.welton.it/davidw/
http://www.dedasys.com/