Hi,

I was trying to do a simple relate according to SqlSoup documentation,
but this error keeps popping every time for every tables I try to
relate even though the foreign keys are right and valid and a manual
SQL join works normally:




>>> db.audits.relate('customer', db.customers)
2011-08-17 16:46:22,560 INFO sqlalchemy.engine.base.Engine SELECT
DATABASE()
2011-08-17 16:46:22,561 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine SHOW
VARIABLES LIKE 'lower_case_table_names'
2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine SHOW
COLLATION
2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine SHOW
VARIABLES LIKE 'sql_mode'
2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `audits`
2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `customers`
2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `users`
2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine ()
>>> a = db.audits.first()
2011-08-17 16:46:39,724 INFO sqlalchemy.engine.base.Engine BEGIN
(implicit)
2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine SELECT
audits.id AS audits_id, audits.site AS audits_site, audits.zeit AS
audits_zeit, audits.responsible AS audits_responsible, audits.prologue
AS audits_prologue, audits.checklists AS audits_checklists,
audits.utype AS audits_utype, audits.customers_id AS
audits_customers_id, audits.users_id AS audits_users_id
FROM audits
 LIMIT ?, ?
2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine (0, 1)


>>> a
MappedAudits(id=179,site='123',zeit=datetime.datetime(2011, 8, 15, 3,
20,
38),responsible='123',prologue='123',checklists='4',utype=None,customers_id=1,users_id=3)


>>> a.customer
2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine SELECT
customers.id AS customers_id, customers.name AS customers_name,
customers.doc AS customers_doc, customers.email AS customers_email,
customers.active AS customers_active
FROM customers
WHERE customers.id = ?
2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine (1,)

Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py", line 474, in _compare
    t2 = [getattr(o, k) for k in L]
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py", line 474, in <listcomp>
    t2 = [getattr(o, k) for k in L]
AttributeError: 'symbol' object has no attribute 'active'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/orm/attributes.py", line 168, in __get__
    return self.impl.get(instance_state(instance),dict_)
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/orm/attributes.py", line 424, in get
    if value in (PASSIVE_NO_RESULT, NEVER_SET):
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py", line 487, in __eq__
    t1, t2 = _compare(self, o)
  File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py", line 476, in _compare
    raise TypeError('unable to compare with %s' % o.__class__)
TypeError: unable to compare with <class
'sqlalchemy.util.langhelpers.symbol'>
>>>



My Foreign keys are all correctly setup and as a simple relation this
should just work, but I have no idea on what is going on with this.
Anybody had the same issue ?


Follows a description of my environment and the related tables:

OS: Tested on both Linux Ubuntu Natty 64bit and Mac OS X 10.7.1 Lion.
Python: Python 3.2.1
SQLAlchemy: 0.7.2
MySQL: 5.5.12
MySQL Python Driver/Connector: OurSQL 0.9.2


Follows the tables description:


=== audits ===

CREATE TABLE `audits` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
  `zeit` datetime NOT NULL COMMENT 'date the audit was started (zeit =
german for time)',
  `responsible` varchar(100) CHARACTER SET latin1 NOT NULL,
  `prologue` text CHARACTER SET latin1 COMMENT 'digest at the
beginning',
  `checklists` varchar(30) DEFAULT ' ',
  `utype` varchar(45) DEFAULT NULL,
  `customers_id` int(10) unsigned NOT NULL,
  `users_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_audits_users1` (`users_id`),
  KEY `utype` (`utype`) USING BTREE,
  KEY `fk_audits_customers1` (`customers_id`),
  CONSTRAINT `fk_audits_customers1` FOREIGN KEY (`customers_id`)
REFERENCES `customers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_audits_users1` FOREIGN KEY (`users_id`) REFERENCES
`users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=235 DEFAULT CHARSET=utf8



=== customers ===

customers | CREATE TABLE `customers` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET latin1 NOT NULL,
  `doc` varchar(25) CHARACTER SET latin1 NOT NULL,
  `email` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
  `active` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `customers_index_name` (`name`),
  UNIQUE KEY `customers_index_doc` (`doc`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8



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.

Reply via email to