Skip to content

Add PostgreSQL JSONB data type.#15

Closed
halybang wants to merge 1 commit intohexya-erp:masterfrom
halybang:master
Closed

Add PostgreSQL JSONB data type.#15
halybang wants to merge 1 commit intohexya-erp:masterfrom
halybang:master

Conversation

@halybang
Copy link

PostgreSQL JSONB data type support.

@codecov
Copy link

codecov bot commented Dec 29, 2017

Codecov Report

Merging #15 into master will decrease coverage by 0.52%.
The diff coverage is 2.7%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #15      +/-   ##
==========================================
- Coverage   82.34%   81.82%   -0.53%     
==========================================
  Files          50       50              
  Lines        5563     5600      +37     
==========================================
+ Hits         4581     4582       +1     
- Misses        741      777      +36     
  Partials      241      241
Impacted Files Coverage Δ
hexya/models/fields_defs.go 87.03% <0%> (-4.65%) ⬇️
hexya/models/db_postgres.go 73.59% <33.33%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfbc241...2995786. Read the comment docs.

@npiganeau
Copy link
Member

Thanks for your proposal.

However, I'm not sure about the use case of this. Actually, I see the interest in a general purpose ORM where you could use it to store arbitrary JSON data while still using the ORM.

But in the case of Hexya, I'm really keen on having its design "business driven". In this respect, each field type is not only a database column type but is above all a business object field type. That is a type which we can find in real life (e.g. a partner name is of type 'char', an invoice date is of type 'date', etc.). Even relation fields (such as Many2One) mimic real life relation (between a partner and a sale order, for instance). Moreover, each type is rendered in the client as a specific widget for user interaction.

In the case of JSONB, I don't see the "real life" aspect of the field type:

  • What kind of business data would we store there ? Wouldn't relation fields (M2O, O2M, ...) be more appropriate here for most use cases ?
  • What would the rendering widget look like ? For which use case ?

@halybang
Copy link
Author

halybang commented Jan 9, 2018

Users can use JSONB data type for IoT projects.
Use hexya to manage IoT device: Device ID, serial, customer relate with ... etc.
Each IoT device can send difference kind of data to Hexya, then Hexya save to database (humanity, gps position ...). With that case, IMHO, using JSONB.

@changwuf31
Copy link

Qor has something like https://github.com/qor/serializable_meta for this kind of use case. It was used for the queue job system, https://github.com/qor/worker. Data is stored in two fields, a kind field (string), eg: "voucher", "shirt", and data field (jsonb), eg: '{"nominal": 10}', '{"size":"M","color":"white"}'.

Another idea would be the polymorphic models.

@sylnsr
Copy link

sylnsr commented Mar 28, 2019

This is actually a feature that I have seen requested a few time from Odoo and long to have myself from Odoo. One major use case is ETL .. as follows (simple outline):

  • Import data from from various disparate sources and store as JSON
  • Use scheduled task or user driven UI to process data from JSON to target tables in ERP

@npiganeau
Copy link
Member

Ok, I can consider this new field type for the ETL use case. But to keep it consistent with concept, we should also have a display widget for JSONB type in https://github.com/hexya-addons/web

If any of you want to make a PR over there for that, I will consider merging this one too.

@halybang
Copy link
Author

Because of hexya changed struct andc code so much, I close this. See PR #69

@halybang halybang closed this Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants