Hello, I am using SQLAlchemy-0.7.1 and i am facing "Deferred loader for attribute" Error while trying to access the table columns in my code.
I have table with huge number of columns around 200 fields and i have defined the schema and entity with hybrid declarative_base approach as below. I have some sample testcases to assert newly inserted values in db with normal python assert statements. When i run my sample test cases i am getting following error: KeyError: "Deferred loader for attribute 'is_updated' failed to populate correctly" Below is my code example due to large number of columns i have not defined entire db Table definition here. test_table = Table("test_table", metadata, Column('test_table_idn', Integer, primary_key=True), Column('test_parent_table_idn', Float, ForeignKey('parent_table_idn')), Column('name', String(10)), Column('is_exported', Integer), . . . #Other columns go here. . #Other columns go here. . #Other columns go here. . . . Column('is_updated', Integer) ) class TestTable(Base): """ """ ___table___ = test_table def set_all_other_attribs(self, **kwargs): #Common method to set other column attributes. for key, value in kwargs: self.key = value class TestTableInserts(TestCase): def setUp(): """ """ self.session = will get session object def test_run(self): tbl_obj = TestTable() dict_to_set(name='test',is_exported=1,.........is_updated=1) tbl_obj.set_all_other_attribs(dict_to_set) self.session.add(tbl_obj) self.session.commit() #Now trying to assert the records in test_table result = self.session.query(TestTable).filter(name == 'test').first() assert result.name == 'test' assert result. <http://result.name/>user_access == 1 assert result. <http://result.name/>web_addr == 'www.myweb.org' assert result.is_updated == 1 #When i tryied to assert the above is_updated column i am getting #KeyError: "Deferred loader for attribute 'is_updated' failed to populate correctly def tearDown(self): self.session.execute('delete from test_table') self.session.close() File "/var/dev/SA/SampleTest/test_sample/test_insert.py", line 79, in test_run >>> assert result.is_updated == 1 File "/var/dev/SA/SampleTest/eggs/SQLAlchemy-0.7.1-py2.6-linux-i686.egg/sqlalchemy/orm/attributes.py", line 170, in __get__ return self.impl.get(instance_state(instance),dict_) File "/var/dev/SA/SampleTest/eggs/SQLAlchemy-0.7.1-py2.6-linux-i686.egg/sqlalchemy/orm/attributes.py", line 439, in get "correctly" % key) KeyError: "Deferred loader for attribute 'is_updated' failed to populate correctly" Please suggest to me fix this error. Just a thought is this error is raised for following reasons. 1. If table column name length is more than 30 chars. 2. If table has large number of columns defined. Thanks, -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.