diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index afb2279e..594339dd 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -3328,7 +3328,7 @@ class SQLTABLE(TABLE):
return
REGEX_TABLE_DOT_FIELD = sqlrows.db._adapter.REGEX_TABLE_DOT_FIELD
fieldmap = dict(zip(sqlrows.colnames, sqlrows.fields))
- tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
+ tablemap = dict(((f.tablename, f.table) if isinstance(f, Field) else (f._table._tablename, f._table) for f in fieldmap.values()))
for table in tablemap.values():
pref = table._tablename + '.'
fieldmap.update(((pref+f.name, f) for f in table._virtual_fields))
diff --git a/gluon/tests/test_sqlhtml.py b/gluon/tests/test_sqlhtml.py
index d0b519a0..1ba9b051 100644
--- a/gluon/tests/test_sqlhtml.py
+++ b/gluon/tests/test_sqlhtml.py
@@ -355,10 +355,10 @@ class TestSQLTABLE(unittest.TestCase):
self.db.commit()
-# def test_SQLTABLE(self):
-# rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL)
-# sqltable = SQLTABLE(rows)
-# self.assertEqual(sqltable.xml(), '
| auth_user.id | auth_user.first_name | auth_user.last_name | auth_user.email | auth_user.username | auth_user.password | auth_user.registration_key | auth_user.reset_password_key | auth_user.registration_id |
|---|
| 1 | Bart | Simpson | user1@test.com | user1 | password_123 | None | | None |
')
+ def test_SQLTABLE(self):
+ rows = self.db(self.db.auth_user.id > 0).select(self.db.auth_user.ALL)
+ sqltable = SQLTABLE(rows)
+ self.assertEqual(sqltable.xml(), b'| auth_user.id | auth_user.first_name | auth_user.last_name | auth_user.email | auth_user.username | auth_user.password | auth_user.registration_key | auth_user.reset_password_key | auth_user.registration_id |
|---|
| 1 | Bart | Simpson | user1@test.com | user1 | password_123 | None | | None |
')
# class TestExportClass(unittest.TestCase):