Commit 687df5e
MONGOID-5140 Atomic #unset method should allow Hash args (in addition to current String/Symbol/Array) (#5034)
* The native MongoDB interface for $unset uses a Hash object rather than an array. Therefore, for consistency, MongoDB should allow a Hash to be the argument to `.unset`.
```
{ $unset: { <field1>: "", ... } }
```
According to [MongoDB's docs](https://docs.mongodb.com/manual/reference/operator/update/unset/):
> The specified value in the $unset expression (i.e. "") does not impact the operation.
So I'm simply taking the array keys, even if the value is nil or false.
* clarify the docstring
* use map instead of collect
* test nil value
Co-authored-by: shields <shields@tablecheck.com>
Co-authored-by: Oleg Pudeyev <code@olegp.name>1 parent f273227 commit 687df5e
File tree
2 files changed
+71
-27
lines changed- lib/mongoid/contextual
- spec/mongoid/contextual
2 files changed
+71
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
182 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
810 | 811 | | |
811 | 812 | | |
812 | 813 | | |
813 | 814 | | |
814 | | - | |
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
825 | 826 | | |
826 | 827 | | |
827 | 828 | | |
828 | 829 | | |
829 | 830 | | |
830 | 831 | | |
831 | 832 | | |
832 | | - | |
| 833 | + | |
| 834 | + | |
833 | 835 | | |
834 | 836 | | |
835 | 837 | | |
| |||
846 | 848 | | |
847 | 849 | | |
848 | 850 | | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
855 | 858 | | |
856 | 859 | | |
857 | 860 | | |
| |||
861 | 864 | | |
862 | 865 | | |
863 | 866 | | |
864 | | - | |
865 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
866 | 898 | | |
867 | 899 | | |
868 | | - | |
869 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
870 | 907 | | |
871 | 908 | | |
872 | 909 | | |
| |||
895 | 932 | | |
896 | 933 | | |
897 | 934 | | |
898 | | - | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
899 | 938 | | |
900 | 939 | | |
901 | 940 | | |
| |||
0 commit comments