mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	models: Replace __id syntax with _id where possible.
model__id syntax implies needing a JOIN on the model table to fetch the id. That's usually redundant, because the first table in the query simply has a 'model_id' column, so the id can be fetched directly. Django is actually smart enough to not do those redundant joins, but we should still avoid this misguided syntax. The exceptions are ManytoMany fields and queries doing a backward relationship lookup. If "streams" is a many-to-many relationship, then streams_id is invalid - streams__id syntax is needed. If "y" is a foreign fields from X to Y: class X: y = models.ForeignKey(Y) then object x of class X has the field x.y_id, but y of class Y doesn't have y.x_id. Thus Y queries need to be done like Y.objects.filter(x__id__in=some_list)
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							11177a40da
						
					
				
				
					commit
					1a8ad796f8
				
			@@ -272,5 +272,5 @@ def subscriber_ids_with_stream_history_access(stream: Stream) -> Set[int]:
 | 
			
		||||
    return set(
 | 
			
		||||
        get_active_subscriptions_for_stream_id(
 | 
			
		||||
            stream.id, include_deactivated_users=False
 | 
			
		||||
        ).values_list("user_profile__id", flat=True)
 | 
			
		||||
        ).values_list("user_profile_id", flat=True)
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user