We return just what psycopg2 gives us, and I'm not able to reproduce "empty
HSTORE as None" - you get NULL as None, empty as {}.
Test case:
from sqlalchemy import Table, MetaData, create_engine
# work around ticket 2680 (reflection, but doesn't matter here)
from sqlalchemy.dialects.postgresql import HSTORE, base
base.ischema_names['hstore'] = HSTORE
engine = create_engine("postgresql://scott:tiger@localhost/test")
connection = engine.connect()
# do raw psycopg2
conn = connection.connection
cursor = conn.cursor()
cursor.execute("create table test (name varchar(10), data hstore)")
cursor.execute("INSERT INTO test (name, data) VALUES(%s, %s)", ('blank', {},))
cursor.execute("INSERT INTO test (name, data) VALUES(%s, %s)", ('null', None,))
cursor.execute("select name, data from test")
# raw psycopg2 output
print cursor.fetchall()
# do SQLAlchemy
t = Table('test', MetaData(), autoload=True, autoload_with=connection)
# SQLAlchemy output
print connection.execute(t.select()).fetchall()
output:
[(u'blank', {}), (u'null', None)]
[(u'blank', {}), (u'null', None)]
On Mar 11, 2013, at 7:07 PM, Charles-Axel Dein <[email protected]> wrote:
> Hi,
>
> Currently, when getting an empty HSTORE column from a model instance, it is
> returned as None. Do you think it would be more logical to have it returned
> as an empty dict?
>
> Thanks,
>
> Charles
>
> --
> 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?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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.