jsonb

Status 400 and Error deserializing List of Objects. No default constructor found

你说的曾经没有我的故事 提交于 2019-12-09 03:58:28
问题 I have this Spring Repository: public interface MessageRepository extends CrudRepository<MessageObject, String>{ public List<MessageObject> findByEmisorOrDestinatario(String emisor, String destinatario); } My DAO is: @Entity @Table(name = "messages") public class MessageObject implements Serializable{ private static final long serialVersionUID = 1L; @Id private String id; private String emisor; private String destinatario; private String mensaje; private String tipo; @JsonFormat(pattern="yyyy

Query on Postgres JSON array field in Rails

僤鯓⒐⒋嵵緔 提交于 2019-12-09 03:17:04
问题 I am trying to query a certain value in a Postgres database. I have a field named groups in the users table that can be represented in either of these ways: 1. groups: {"data"=>[{"serie"=>5, "year"=>3, "specialization"=>"Matematica", "management_id"=>1, "group_number"=>2}, {"serie"=>5, "year"=>3, "specialization"=>"Matematica", "management_id"=>1, "group_number"=>2}]} 2. groups: [{"serie"=>5, "year"=>3, "specialization"=>"Matematica", "management_id"=>1, "group_number"=>2}, {"serie"=>5, "year

In Django 1.9, what's the convention for using JSONField (native postgres jsonb)?

戏子无情 提交于 2019-12-09 02:12:21
问题 Django highly suggests not to use null=True for CharField and TextField string-based fields in order not to have two possible values for "no data" (assuming you're allowing empty strings with blank=True ). This makes total sense to me and I do this in all my projects. Django 1.9 introduces JSONField, which uses the underlying Postgres jsonb data type. Does the suggestion above carry over to JSONField (i.e. blank=True should be used instead of null=True )? Or, should null=True be used instead?

How to convert postgresql 9.4 jsonb to object without function/server side language

佐手、 提交于 2019-12-09 00:34:15
问题 Is it possible to transform postgresql 9.4 jsonb data without creating function and without using any server side programming language? CREATE TABLE test (id SERIAL PRIMARY KEY,data JSONB); INSERT INTO test(data) VALUES('{"a":1,"b":2}'); INSERT INTO test(data) VALUES('{"a":3,"b":4,"c":7}'); INSERT INTO test(data) VALUES('{"a":5,"b":5,"d":8}'); SELECT * FROM test; id | data ----+------------------------- 1 | {"a": 1, "b": 2} 2 | {"a": 3, "b": 4, "c": 7} 3 | {"a": 5, "b": 5, "d": 8} to

Effectively searching through entire 1 level nested JSONB in Postgres

左心房为你撑大大i 提交于 2019-12-08 19:14:12
问题 Let's say we need to check if a jsonb column contains a particular value matching by a substring in any of the value (non-nested, only first level). How does one effectively optimize a query to search entire JSONB column (this means every key) for a value? Is there some good alternative to doing ILIKE %val% on jsonb datatype casted to text? jsonb_each_text(jsonb_column) ILIKE '%val%' As an example consider this data: SELECT '{ "col1": "somevalue", "col2": 5.5, "col3": 2016-01-01, "col4":

Using Postgres JSONB query with Spring Data and bind parameter fails with InvalidDataAccessApiUsageException

亡梦爱人 提交于 2019-12-08 13:41:19
问题 I am currently looking for a solution for the exception org.springframework.dao.InvalidDataAccessApiUsageException: Parameter with that position [1] did not exist; My current @Query annotation is: @Query( nativeQuery = true, value = "SELECT * FROM thgcop_order_placement WHERE \"order_info\" @> '{\"parentOrderNumber\":\" :param \"}'") I guess the position [1] did not exist comes from it being in double quotes plus double quote plus single quote. How can I make this work? The query is using

Indexing jsonb for numeric comparison of fields

余生长醉 提交于 2019-12-08 08:56:04
问题 I've defined a simple table with create table resources (id serial primary key, fields jsonb); And it contains data with keys (drawn from a large set) and values between 1 and 100, like: id | fields --------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 | {"tex": 23, "blair": 46, "cubic": 50, "raider": 57, "retard": 53, "hoariest": 78,

Find position of object in postgres jsonb array

﹥>﹥吖頭↗ 提交于 2019-12-08 05:26:45
问题 I have an array of objects that looks like this within the jsonb value column of a table: "west": [ {"id": "aa92f346-7a93-4443-949b-4eab0badd983", "version": 1}, {"id": "cd92e346-6b04-3456-050a-5eeb0bddd027", "version": 3} ] I'm aiming to remove certain objects from this array based on their id and version like so: SELECT value::jsonb #- '{west, 1}' FROM game.settings; However, the 1 should not be hard-coded, but rather should equal the position of the object within the array which matches

Find position of object in postgres jsonb array

大城市里の小女人 提交于 2019-12-08 05:12:30
I have an array of objects that looks like this within the jsonb value column of a table: "west": [ {"id": "aa92f346-7a93-4443-949b-4eab0badd983", "version": 1}, {"id": "cd92e346-6b04-3456-050a-5eeb0bddd027", "version": 3} ] I'm aiming to remove certain objects from this array based on their id and version like so: SELECT value::jsonb #- '{west, 1}' FROM game.settings; However, the 1 should not be hard-coded, but rather should equal the position of the object within the array which matches the id and version I'm looking for (in this case "id": "cd92e346-6b04-3456-050a-5eeb0bddd027", "version":

Flattening Postgres nested JSONB column

你离开我真会死。 提交于 2019-12-08 00:13:48
问题 I'm looking to see how to flatten data nested in a JSONB column. As an example, say we have the table users with user_id(int) and siblings(JSONB) With rows like: id | JSONB --------------------- 1 | {"brother": {"first_name":"Sam", "last_name":"Smith"}, "sister": {"first_name":"Sally", "last_name":"Smith"} 2 | {"sister": {"first_name":"Jill"}} I'm looking for a query that will return a response like: id | sibling | first_name | last_name ------------------------------------- 1 | "brother" |