def test_json_length_type(self): results = list( JSONModel.objects.annotate( x=JSONLength('attrs'), ).filter(x__range=[3, 5]), ) assert results == [self.obj]
def test_json_length_path(self): results = list( JSONModel.objects.annotate( x=JSONLength('attrs', '$.sub'), ).values_list('x', flat=True), ) assert results == [len(self.obj.attrs['sub'])]
def test_json_length_path(self): results = list( JSONModel.objects.annotate(x=JSONLength("attrs", "$.sub")).values_list( "x", flat=True ) ) assert results == [len(self.obj.attrs["sub"])]
def test_json_length(self): results = list( JSONModel.objects.annotate(x=JSONLength('attrs')).values_list( 'x', flat=True)) assert results == [len(self.obj.attrs)]
def test_json_length_output_field(self): results = list( JSONModel.objects.annotate(x=JSONLength( "attrs", output_field=IntegerField())).values_list("x", flat=True)) assert results == [len(self.obj.attrs)]