I'm the one who opened the issue.
The worst thing is that while you can insert a record with arbitrary key 
into a table, you won't be able to delete it later. 
So even if you create an another function for the counter the problem will 
still exist.

Imo if you do delete_counter you will have to create a create_counter as 
well, so that all this 'counter' feature would be an on-demand one. But it 
could be more complicated than this - a record can have multiple counters, 
and there's an autogeneration of counter access functions in model 
definition with -counter(foo_counter) module attribute.






понедельник, 1 декабря 2014 г., 15:58:20 UTC+3 пользователь David Welton 
написал:
>
> 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/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/d50c5ad8-2293-4977-be60-158b4dd152f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to