Hi, thanks for all your work :) >> I can't set neither polymorphic_on > > set this using a string - polymorphic_on = 'type'.
Oh, Indeed that works. >> nor sort_on columns in mapper > > order_by? OK, I'm not a huge fan of mapper order_by but we can come up with > something on that.... Thanks for solving this. >> There is no way to ignore just SAWarnings just on some tables now, >> only either turn them off for all tables (around prepare call) or >> reflect the tables explicitly before calling prepare. (otherwise I >> keep getting the warnings for indexes/columns sqlalchemy does not >> understand) > > you can silence warnings using the warnings filter in Python. There's lots > of things SQLA doesn't know how to reflect in PG, particularly functional > indexes, so the options are it ignores them silently, raises an error, or > warns+ignores. I must have been unclear in my ramblings, sorry. I know I can silence the warnings, but in reflected schema arrangement I could silence warnings for just one one table: warnings.simplefilter('ignore', SAWarning) Table("items", metadata, autoload=True, autoload_with=engine, extend_existing=True) warnings.simplefilter('default', SAWarning) If I want to do the same for the *normal* declarative I just surround the class definition with same code. With Deferred declarative I can must turn off all warnings by doing: warnings.simplefilter('ignore', SAWarning) Base.prepare() warnings.simplefilter('default', SAWarning) Which hides warnings for all the tables, instead of just the 1 table I know has something fishy. Though it is just a minor issue. The perfect solution for me would be being able to tell sqlalchemy to ignore some columns or indexes on the class explicitly. Like: class SearchTerm(Base): __tablename__ = 'search_terms' terms = Column(Ignore) # or something like that so that if something other than that column being unrecognized causes the warning I would see it. (I had warnings that happen during prepare point some real bugs so I don't want to run with them turned off just because I have a ts_vector column on one of my tables and a functional index on another one) but still, the workaround of refleting the offending tables before doing prepare works. Overall the refactoring from simple reflected schema saved a bunch of code. 400 lines added, 600 removed according to diffstat :) >> so that all the tables would get defined before models. I can't come >> up with an sqlite based testcase at the moment. >> Without this some I was having some_table has no column id errors. > > Dependencies between mapper tables come up at mapper creation time only with > joined inheritance - these mappers should already be created in the same > order. Dependencies between mappers due to relationship() don't attempt to > resolve at this stage, so that wouldn't be the issue either. A dependency > due to column_property() with some related table, maybe, but that requires > explicit access to the tables anyway. > > A stack trace here would be extremely helpful. File "/home/ignas/src/busy/src/busy/models/meta.py", line 25, in prepare thingy.map() File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/ext/declarative.py", line 1371, in map **self.mapper_args File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/orm/__init__.py", line 1137, in mapper return Mapper(class_, local_table, *args, **params) File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/orm/mapper.py", line 204, in __init__ self._configure_pks() File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/orm/mapper.py", line 793, in _configure_pks ignore_nonexistent_tables=True) File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/sql/util.py", line 596, in reduce_columns fk_col = fk.column File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/util/langhelpers.py", line 524, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/home/ignas/.buildout/eggs/SQLAlchemy-0.8.0b1dev-py2.6-linux-i686.egg/sqlalchemy/schema.py", line 1411, in column table.name, key) Problem is this arrangement: class User(Base): __tablename__ = 'users' class WallPostStar(Base): __tablename__ = 'wall_post_stars' user = relation(User, backref="wall_post_stars") class WallPost(Base): __tablename__ = 'wall_posts' stars = relation(WallPostStar, backref='wall_post') author = relation(User, backref="wall_posts") if I put wall post star class *after* wall post class, it starts to work as it should. (the error happens when mapping wall post star class before wall post class is mapped) Ignas -- 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.