1

I have this datastore model:

class Person(db.Model):
    person_name = db.StringProperty(required = True)        
    nacionality = db.StringProperty(required = True)
    marital_status = db.StringProperty(required = True)
    profession = db.StringProperty(required = True)
    SSN = db.IntegerProperty(required = True)
    driver_license = db.IntegerProperty(required = True)
    address = db.PostalAddressProperty(required = True)

In this Model, person_name could be something like this: 'Carl Sagan' (there is only on property for the entiry name). But when I query it, this way:

    searched_name = 'Carl'
    p = Person.all()
    persons = p.filter('person_name >=', searched_name)

I got, as a result, names which doesn't begin with 'Carl' or neither have 'Carl' in any part of the name. If I query this way: persons = p.filter('person_name >=', searched_name) I got none result (even 'Carl Sagan' isn't found). So, I'd like to know: what is the best filter to this kind of query? (quering a complete name property using only the first name)?

Lucas Zamboulis
  • 2,494
  • 5
  • 24
  • 27
craftApprentice
  • 2,697
  • 17
  • 58
  • 86

1 Answers1

1

String filter works as it was comparing chars starting beginning of string. You can do something like this:

p.filter('person_name >=', searched_name)
p.filter('person_name <', searched_name + u'\ufffd')
Peter Knego
  • 79,991
  • 11
  • 123
  • 154