Hi,

I'm getting some unexpected results when using a JSONB column to store the 
results of a Python dictionary.

I have defined a column as follows:

rrp_i8n = Column(JSONB, default={})

What I'm finding is that the method of setting the value is critical (when 
it should not be). Test case as follows:



p0 = session.query(Product)[0]
p1 = session.query(Product)[1]

p0.rrp_i8n  # {}
p1.rrp_i8n  # {}

# Set value one way
p0.rrp_i8n['US'] = 999
p0.rrp_i8n  # {'US': 999}

# Set value another way
p1.rrp_i8n = {'US': 999}
p1.rrp_i8n  # {'US': 999}

# Check that the values are the same ...
p0.rrp_i8n == p1.rrp_i8n  # True

session.commit()

# Now the values are different!
p0.rrp_i8n  # {}
p1.rrp_i8n # {'US': 999}


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to