title: SQLAlchemy subquery getting AttributeError: 'Query' object has no attribute 'is_clause_element'
body: <p>I am having trouble subquerying from main query function. My query is a function inside a class like this</p>
  
  <pre><code>class MyClass():
      ...
      ...
      @property
      def main_query(self):
          main_query = session.query(MainTable)
                              .join(otherTable)
                              .filter(otherTable.id = self.id)
          return main_query
  </code></pre>
  
  <p>for some reason when I try to do something as simple as the following in another module:</p>
  
  <pre><code>q = MyClass.main_query(111)   # 111 is the id here
  print(str(q))                 # I can see this print, it prints the correct query statement
  subquery_maxdate = session.query(func.max(Table1.date).label("max_date")).subquery()
  query = DBSession.query(q, subquery_maxdate)    #This gives me an error  
  
  AttributeError: 'Query' object has no attribute 'is_clause_element'    
  </code></pre>
  
  <p>I am trying to branch off subqueries from the <code>main_query</code> depending on user drop-down selection.</p>
  
  <p>It seems like I cannot run another query from the class, cause when I just simply try this: </p>
  
  <pre><code>q = DBSession.query(q)   # This already gives me the error
  
  AttributeError: 'Query' object has no attribute 'is_clause_element'
  </code></pre>
  
  <p>Can someone please help me out here.</p>