On 6/18/14, 2:06 AM, rpkelly wrote:
> It seems like passing literal_binds=True to the call to
> sql_compiler.process in get_column_default_string will work, so long
> as SQLAlchemy can convert the values to literal binds. Which, in the
> example given, isn't the case.
the long standing practice for passing literals into server_default and
other places is to use literal_column():
server_default=func.foo(literal_column("bar"))),
for the array, you need to use postgresql.array(), not func.array().
It will work like this:
tbl = Table("derp", metadata,
Column("arr", ARRAY(Text),
server_default=array([literal_column("'foo'"),
literal_column("'bar'"),
literal_column("'baz'")])),
)
the docs suck.
https://bitbucket.org/zzzeek/sqlalchemy/issue/3086/server_default-poorly-documented
is added (referring to
http://docs.sqlalchemy.org/en/rel_0_9/core/defaults.html#server-side-defaults).
then for literal_binds. We've been slowly adding the use of this new
parameter with a fair degree of caution, both because it can still fail
on any non-trivial kind of datatype and also because a feature that
bypasses the "bound parameter" logic is just something we've avoided for
years, due to the great security hole it represents. We added it for
index expressions in #2742.
https://bitbucket.org/zzzeek/sqlalchemy/issue/3087/literal_binds-in-server_default
will add it for server_default. it's 1.0 for now but can be
potentially backported to 0.9.5.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.