Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2017-04-05 Thread mike bayer
On 04/05/2017 07:42 PM, davor wrote: It seems that besides name_for_scalar_relationship also generate_relationship has to be adjusted since the backref name will also not be unique. name_for_collection_relationship is usually what you need for bi-directional many-to-many Are here any

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2017-04-05 Thread davor
It seems that besides name_for_scalar_relationship also generate_relationship has to be adjusted since the backref name will also not be unique. Are here any options to make the name more unique? On Wednesday, 6 January 2016 11:43:54 UTC+1, yoch@gmail.com wrote: > > For now, I don't have

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-06 Thread yoch . melka
For now, I don't have a sufficiently comprehensive view of the automap process and its effects to make a pull-request. Maybe one day I'll take time to learn more about that, and to understand the corresponding tests. Thank you Le lundi 4 janvier 2016 05:19:17 UTC+2, Michael Bayer a écrit : > >

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
On 01/03/2016 02:43 PM, yoch.me...@gmail.com wrote: > I've added theses lines here > > : > > | >

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
there's actually two if you put your check everywhere it would be needed (I already tried when you first suggested that it warn, which is the origin of my response that this is not a one liner). the warning here is doable it just needs more state to be tracked as automap runs. if you want to

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread yoch . melka
Okay, I have one test failed for automap : ~/sqlalchemy $ ./sqla_nose.py test.ext.test_automap .E.. == ERROR: test.ext.test_automap.AutomapTest.test_relationship_explicit_override_m2o

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread yoch . melka
OK, thanks you. I think it's a good idea to issue a warning in such cases. Best regards Le samedi 2 janvier 2016 19:18:12 UTC+2, Michael Bayer a écrit : > > > > On 01/02/2016 11:38 AM, yoch@gmail.com wrote: > > Thank you. > > > > I hesitate between using this way, or explicitly specify

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
On 01/03/2016 07:00 AM, yoch.me...@gmail.com wrote: > OK, thanks you. > > I think it's a good idea to issue a warning in such cases. unfortunately this is a difficult situation to detect since it is a valid use case to present a mapped class that already has relationships present on it, which

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread yoch . melka
I've added theses lines here : if relationship_name in map_config.properties: msg = "%s

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-02 Thread Mike Bayer
On 01/02/2016 11:38 AM, yoch.me...@gmail.com wrote: > Thank you. > > I hesitate between using this way, or explicitly specify the relationship > (is this a good idea? In my test I found 3 relations after prepare()) : it's fine to do that. Automap is still building its own relationship as well

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-02 Thread yoch . melka
Thank you. I hesitate between using this way, or explicitly specify the relationship (is this a good idea? In my test I found 3 relations after prepare()) : class Thermostat(Base): __tablename__ = 'thermostats' idbuiltin = Column(Integer, ForeignKey('device.id')) idthermometer =

[sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-01 Thread yoch . melka
Hi all, I use automap with database reflection to import schema with sqlalchemy. In case I have two relationships on same foreign key in some table, only one relationship is created by prepare(), the second one seems overwrited. My table looks like : Table('thermostat', Base.metadata,

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-01 Thread Mike Bayer
you need to use the name generation functions name_for_scalar_relationship() and/or name_for_collection_relationship() to produce different names in each case. The "constraint" parameter passed as we see in