Actually, modifying the parameter in cursor_execute() for Postgres
behaves exactly as Oracle does now in sqla without and proxy.
sqla thinks it is writing an '' to the database, but Oracle is actually
changing that to NULL, so it behaves the same.
after and update to '', if you ask "field is None" you get False. But
if you expire the attribute and then ask again you get True.
On 11/4/2010 5:07 PM, Michael Bayer wrote:
On Nov 4, 2010, at 4:06 PM, Kent Bower wrote:
If I intercept strings that are empty and replace with None, is there potential problems
because the database record and the python object are "out of sync"?
Thereafter, will sqla believe the column value has changed and try to write again on next
flush()?
It would seem likely that small issues could arise, since you're effectively
breaking round trips. It would not perceive any net changes to columns that
haven't been touched, though if you set '' on an attribute that was already '',
that will obviously generate a change event since it would have loaded the
value as a None.
For control over round trips you could override String with a TypeDecorator.
On 11/4/2010 11:42 AM, Michael Bayer wrote:
On Nov 4, 2010, at 11:16 AM, Kent wrote:
We are writing an application that can run on PostgreSQL or Oracle.
Since postgres treats NULL and '' (empty string) differently, while
Oracle treats '' as NULL, this can cause subtle behavior differences
based on the underlying database.
Can you think of a way I could easily intercept all UPDATE and INSERT
column values, and, if the value is the empty string, replace with
None/null?
Thanks in advance if you can point me in the right direction.
the current method on this is the ConnectionProxy:
http://www.sqlalchemy.org/docs/core/interfaces.html#sqlalchemy.interfaces.ConnectionProxy
Kent
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.