9
데이터베이스 경로에 상대 경로로 파일 경로를 저장하고 있지만 매핑 할 때 하이브리드 속성을 사용하여 절대 경로로 변환합니다. 이 속성을 사용하여 쿼리 할 때 오류가 발생합니다. 여기에 모델의 :SQLAlchemy의 하이브리드 속성 쿼리
class File(Base):
__tablename__ = 'files'
...
_f_path = Column(Unicode(30))
...
@hybrid_property
def f_path(self):
env = shelve.open('environment')
return os.path.join(env['project_dir'], self._f_path)
@f_path.setter
def f_path(self, _f_path):
self._f_path = _f_path
나는 (REF는 유니 코드 문자열)이 쿼리를 실행하면 :
File "/Users/Ben/Dropbox/Giraffe/giraffe_server/giraffe/file_handlers/maya.py", line 135, in process_file
rf = session.query(File).filter_by(f_path=str(ref)).first()
File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/orm/query.py", line 1211, in filter_by
for key, value in kwargs.iteritems()]
File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/orm/util.py", line 597, in _entity_descriptor
return getattr(entity, key)
File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/ext/hybrid.py", line 681, in __get__
return self.expr(owner)
File "/Users/Ben/Dropbox/Giraffe/giraffe_server/giraffe/model.py", line 133, in f_path
print "\n\n\n[model.py:[email protected]_path hybrid_property] returning: ", os.path.join(env['project_dir'], self._f_path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 66, in join
if b.startswith('/'):
File "build/bdist.macosx-10.7-intel/egg/sqlalchemy/sql/expression.py", line 3426, in __nonzero__
raise TypeError("Boolean value of this clause is not defined")
TypeError: Boolean value of this clause is not defined
Perfect. 나는 SQLAlchemy와 SQL에 관해서 더 많이 배웠다. 매우 감사합니다. –