Cockroachdb sqlalchemy dialect doesn't fully support JSONB
See original GitHub issueI’m testing recently added JSONB.
Setup:
python3.6
psycopg2==2.7.4
SQLAlchemy==1.2.5
cockroachdb v2.0.1
I was able to save a sample data into the database. This is how it looks in a dump file:
{
"id" : "2a4b4578-1a5d-455b-9317-c90c5f3afe15",
"enabled" : true,
"language" : "en-us",
"ui_metadata" : "{\"origin\": \"111\", \"ui\": null, \"version\": null}",
}
I’m now loading data with sqlalchemy session.query.all() Error:
return json_deserializer(value)
File "/usr/local/lib/python3.6/json/__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'dict'
https://bitbucket.org/zzzeek/sqlalchemy/src/7541d9b258e4d0c115d6160592ac7e17f8fd50cc/lib/sqlalchemy/sql/sqltypes.py?at=master&fileviewer=file-view-default#sqltypes.py-2145:2155 https://github.com/cockroachdb/cockroachdb-python/blob/master/cockroachdb/sqlalchemy/dialect.py
This line fails:
json_deserializer = dialect._json_deserializer or json.loads
Because there is no _json_deserializer
and it tries to call json.loads on a python dict.
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Cockroachdb sqlalchemy dialect doesn't fully support JSONB
I'm testing recently added JSONB. Setup: python3.6 psycopg2==2.7.4 SQLAlchemy==1.2.5 cockroachdb v2.0.1 I was able to save a sample data ...
Read more >JSONB | CockroachDB Docs
Returns the JSON value pointed to by the variadic arguments. See Update an array element. For the full list of supported JSONB functions,...
Read more >What's New in v21.2 | CockroachDB Docs
Sequelize, a Javascript object-relational mapper (ORM), and Alembic, a schema migration tool for SQLAlchemy users, are now fully supported. We have also ...
Read more >What's New in v2.1 | CockroachDB Docs
CockroachDB v2.1 is no longer supported. For more details, see the Release Support Policy. Get future release notes emailed to you: *.
Read more >What's New in v21.1 | CockroachDB Docs
The format for SQL audit, execution, and query logs has changed from a crude space-delimited format to JSON. To opt out of this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve just uploaded a new version to pypi.
@bdarnell
I’m not using JSON 😃
I’m using
dbeaver
as a gui tool and it says that data type of that column isjsonb
. So when my code throwsTypeError: the JSON object must be str, bytes or bytearray, not 'dict'
, it somehow detects JSON instead of JSONB.