full script is attached. Works in 0.9, 0.8.
On Apr 18, 2014, at 1:50 AM, Joshua Ma m...@josh.ma wrote:
I tried with the sample code, and I get the following:
File /Users/joshma/aurelia/benchling/models/folder.py, line 273, in
module
configure_mappers()
File
Awesome, thanks so much for the quick response.
On Sun, Apr 13, 2014 at 7:00 PM, Michael Bayer mike...@zzzcomputing.comwrote:
you need to turn your __table_args__ into a callable:
@declared_attr
def __table_args__(cls):
return (Index(…, func.lower(cls.name), …), )
or just use a
Hi Mike,
In hindsight I might have responded prematurely - got around to trying it
and with text() I get the following:
__table_args__ = (
...
Index('folder_lower_name_idx', text('lower(name)'),
postgresql_ops={'name': 'text_pattern_ops'}),
)
File
OK well this stage to create an Index is just not deferred enough, and text()
is not supported. Declarative has to make a name column that is part of
MyModel by copying it because it's coming from a mixin and that just hasn't
happened yet, the Column is not the right object yet. The Table
I tried with the sample code, and I get the following:
File /Users/joshma/aurelia/benchling/models/folder.py, line 273, in
module
configure_mappers()
File
/Users/joshma/.envs/aurelia/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py,
line 2560, in configure_mappers
Is there a way to create a functional index in a declarative model without
referencing the actual column? I currently have something like
class MyModel(db.Base):
name = db.Column('name', db.String(255))
__table_args__ = (
Index('mymodel_lower_name_idx', func.lower(name),
you need to turn your __table_args__ into a callable:
@declared_attr
def __table_args__(cls):
return (Index(..., func.lower(cls.name), ...), )
or just use a string for your functional index:Index(...,
text(LOWER(name)), ...)
On Apr 13, 2014, at 9:22 PM, Joshua Ma m...@joshma.com