flask-sqlalchemy
                                
                                 flask-sqlalchemy copied to clipboard
                                
                                    flask-sqlalchemy copied to clipboard
                            
                            
                            
                        Using sqlalchemy.ext.compiler with BINDS
When using the compiles decorator as in this example:
http://docs.sqlalchemy.org/en/rel_0_8/core/compiler.html#compiling-sub-elements-of-a-custom-expression-construct
Queries constructed in this way do not seem to obey the bind_key in the info dictionary on the table.
In this code, I have added some debugging:
@compiler.compiles(InsertFromSelect)
   def visit_insert_from_select(element, compiler, **kwargs):
       print element.table.info
       return 'INSERT INTO %s %s' % (
           compiler.process(element.table, asfrom=True),
           compiler.process(element.select))
That info dictionary has the following value:
{"bind_key": "reporting"}
Which is the correct bind key. However, it is still attempting to query the default database specified in SQLALCHEMY_DATABASE_URI.
When I do a simple select('*', from_obj=[MY_TABLE]) this works as expected. It seems to be lost on the compiled stuff.
Any thoughts?
May be related to #222.
Assuming this is about metadata per bind, this would be fixed by #1087. Given the age, I'm going to close this, please reopen with a reproducible example if it's still an issue after that PR.