File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,6 @@ def initialize(options = {})
6161        @name  =  options . fetch ( :name ,  :active_record ) 
6262        @feature_class  =  options . fetch ( :feature_class )  {  Feature  } 
6363        @gate_class  =  options . fetch ( :gate_class )  {  Gate  } 
64- 
65-         warn  VALUE_TO_TEXT_WARNING  if  value_not_text? 
6664      end 
6765
6866      # Public: The set of known features. 
@@ -289,15 +287,23 @@ def result_for_gates(feature, gates)
289287      # Check if value column is text instead of string 
290288      # See https://github.com/flippercloud/flipper/pull/692 
291289      def  value_not_text? 
292-         @gate_class . column_for_attribute ( :value ) . type  != :text 
290+         with_connection ( @gate_class )  do  |connection |
291+           @gate_class . column_for_attribute ( :value ) . type  != :text 
292+         end 
293293      rescue  ::ActiveRecord ::ActiveRecordError  =>  error 
294294        # If the table doesn't exist, the column doesn't exist either 
295295        warn  "#{ error . message }  
296296      end 
297297
298298      def  with_connection ( model  =  @feature_class ,  &block ) 
299+         warn  VALUE_TO_TEXT_WARNING  if  !warned_about_value_not_text?  && value_not_text? 
299300        model . connection_pool . with_connection ( &block ) 
300301      end 
302+ 
303+       def  warned_about_value_not_text? 
304+         return  @warned_about_value_not_text  if  defined? ( @warned_about_value_not_text ) 
305+         @warned_about_value_not_text  =  true 
306+       end 
301307    end 
302308  end 
303309end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments