On Jun 7, 2013, at 9:31 AM, Richard Gerd Kuesters <rich...@humantech.com.br> wrote:
> Hi all! > > I'm refactoring a database schema but I need it to mantain reverse > compatibility with older versions of our software - using views. > > But, to avoid confusion to other developers, new tables have two underscores > as a prefix, like: > > > class Base(object): > > @declared_attr > def __tablename__(cls): > return "__%s" % to_python_case(cls.__name__) > > > Now I want to add column prefixes too. I know I can append to this Base > object: > > __mapper_args__ = dict( > column_prefix='_' > ) > > But, when I inherit this new base on classes that I need to use > __mapper_args__, column names probably won't have prefixes. Any ideas, > perhaps an event listener to prepend the underscore into *all* column names? one idea is you can intercept how mapper() is called by declarative by overriding __mapper_cls__, like: @classmethod def __mapper_cls__(cls, *args, **kw): kw['column_prefix'] = '_' return mapper(*args, **kw) > > > Cheers, > Richard. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.