title: Why my SQLAlchemy query.flter works only on some attribute?
body: <p>I am learning SQLAlchemy of Python.</p>
  
  <p>Below is an example I am useing.</p>
  
  <p>First I generate a datafile contains puppy information like below:</p>
  
  <pre><code>class Puppy(Base):
      __tablename__ = 'puppy'
      id = Column(Integer, primary_key=True)
      name = Column(String(250), nullable=False)
      gender = Column(String(6), nullable = False)
      dateOfBirth = Column(Date)
      shelter_id = Column(Integer, ForeignKey('shelter.id'))
      weight = Column(Numeric(10))
  
  
  male_names = ["Bailey", "Max", ...just some names..., "Luke", "Henry"]
  
  female_names = ['Bella', 'Lucy', ...just some names..., 'Honey', 'Dakota']
  
  def CreateRandomAge():
      today = datetime.today()
      days_old = randint(0,540)
      birthday = today - timedelta(days = days_old)
      return birthday
  
  def CreateRandomWeight():
      return random.uniform(1.0, 40.0)
  
  for i,x in enumerate(male_names):
      new_puppy = Puppy(name = x, gender = "male", dateOfBirth = CreateRandomAge(), weight= CreateRandomWeight())
      session.add(new_puppy)
      session.commit()
  
  for i,x in enumerate(female_names):
      new_puppy = Puppy(name = x, gender = "female", dateOfBirth = CreateRandomAge(), weight= CreateRandomWeight())
      session.add(new_puppy)
      session.commit()
  </code></pre>
  
  <p>Now I want to filter some kinds of puppies as below:</p>
  
  <pre><code>testpuppy = session.query(Puppy).filter_by(name='Lucy')
  print(testpuppy)
  
  birthdate = datetime.today() - timedelta(days=180)
  smallpuppy = session.query(Puppy).filter_by(dateOfBirth &lt; birthdate)
  print(smallpuppy)
  </code></pre>
  
  <p>Then it is strange, because the testpuppy passed, I can get Lucy, but the dateofBirth can not pass, every time I want to get these smallpuppies, I just got an error </p>
  
  <pre><code>NameError: name 'dateOfBirth' is not defined
  </code></pre>
  
  <p>I really can not understand, why my filter can only be operated on some attribute, where is wrong?</p>