Just a quick update ... Mac OS X is case preserving but case insensitive so a query directly within mysql for table "USER" using "user" will result correctly. So this just deepens the mystery more - on UNIX either MySQLdb or SQLAlchemy is preserving the case of the table name as "USER" but on Mac OS X it is not preserving it, which should work, but whatever routine that underlies the search for the foreign key in the example I have given is not working.
On Oct 1, 10:27 pm, rootsmith <[email protected]> wrote: > Previously I was doing development of a project on an Ubuntu 9.04 > machine with MySQL 5.0 and just recently switched to doing development > on a MacBook Pro. I installed identical versions of MySQL on the > MacBook. I used the exact same source files and installed the same > versions of all libraries for the project, however, when I try to > initialize the model on the MacBook I get the following stack trace: > > File "/Users/kevin/mydevenv/lib/python2.6/site-packages/ > SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/__init__.py", line 751, in > mapper > return Mapper(class_, local_table, *args, **params) > File "/Users/kevin/mydevenv/lib/python2.6/site-packages/ > SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/mapper.py", line 194, in > __init__ > self._configure_inheritance() > File "/Users/kevin/mydevenv/lib/python2.6/site-packages/ > SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/orm/mapper.py", line 239, in > _configure_inheritance > self.inherit_condition = sqlutil.join_condition > (self.inherits.local_table, self.local_table) > File "/Users/kevin/mydevenv/lib/python2.6/site-packages/ > SQLAlchemy-0.5.6-py2.6.egg/sqlalchemy/sql/util.py", line 135, in > join_condition > "between '%s' and '%s'" % (a.description, b.description)) > sqlalchemy.exc.ArgumentError: Can't find any foreign key relationships > between 'USER' and 'MANAGER' > > This is despite the fact that there is a foreign relation between the > two as follows on the MANAGER table: > > CONSTRAINT FK_MANAGER_USER FOREIGN KEY (user_id) > REFERENCES `USER`(user_id) > > I have traced the problem so far to the fact that on Ubuntu, the > ForeignKey in SQLAlchemy is built as ForeignKey(u'USER.user_id') and > on the Mac it is ForeignKey(u'user.user_id'). This has been confirmed > by tracing the code into sql.util.join_condition where the call > fk.get_referant() is being made. > > Note again, this is the EXACT SAME code running on both machines. I > don't know if it is a MySQL setting (unlikely), MySQLdb, or SQLAlchemy > that is causing the incorrect case issue on the table name. Does > anyone know off hand what might be going on here? > > Just to confirm, the table in the database is called "USER" and > therefore any search for "user" will not yield any results. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
