0

GQL 작동 방식을 이해하지 못해서 발생한 문제가 있습니다. (이것이 첫 번째 날입니다.) Google App Engine (현재 로컬)에서 google.appengine.ext.db 데이터 저장소를 사용하고 있습니다.Google AppEngine for Python의 GQL에서 간단한 데이터 저장/검색

나는 단순히 특정 ID를 가진 사용자를 만든 다음이 ID가있는 레코드 만 포함하도록 필터링하여 검색하려고합니다. 이 작업을 시도해도 아무 것도 반환하지 않지만 모든 작업을 완료하고 반복하여 ID를 비교하면 레코드를 찾습니다. 여기 내가 확실히 보지 못하는 어리석은 실수가 분명히있다. 코드는 다음과 같습니다.

def datastore_key(): 
    return db.Key.from_path('MyUsers', 'all') 

class MyUser(db.Model): 
    my_id = db.TextProperty() 


[...] 

user = MyUser(parent=datastore_key()) 
user.my_id = "7wjew1" 
user.put() 

users = MyUser.all() 
users.ancestor(datastore_key()) 
users.filter("my_id = ", "7wjew1") # WTF - why isn't this working??? 
print users[0] # is None, users list is empty 

# now, let's get all users 
users = MyUser.all() 
users.ancestor(datastore_key()) 
# and iterate through the list to check for ids 
for user in users: 
    if user.linkedin_id == user_id: 
     print "ids are the same" 
     # surprise, it prints the "ids are the same" - wtf? 
+1

OK 가끔 질문을 작성하면 즉시 답변을 얻을 수 있습니다. TextProperty를 StringProperty로 바꿨다. :) – michuk

답변

1

확인 제가 궁금한 점이 있으면 답변을 직접 작성해 두는 것이 좋습니다. 나는 TextPropertyStringProperty으로 바 꾸었습니다. 작동했습니다 :

+0

'TextProperty'는 큰 텍스트 얼룩을위한 것이기 때문에 이것은 궁금 할 것이다. 존재하지 않는 속성이나 인덱스되지 않은 속성을 필터링하려고하면'filter()'메서드는 에러를 발생시키지 않고 그냥 아무것도 반환하지 않습니다. –

관련 문제