[MDEV-11897] Where more/less/more or equal/less or equal conditions for JSON nested arrays dosn't work Created: 2017-01-24 Updated: 2017-01-28 Resolved: 2017-01-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | JSON |
| Affects Version/s: | 10.2.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Andrii | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | JSON | ||
| Environment: |
Ubuntu 14.04 LTS |
||
| Description |
|
Conditions working fine for the first level keys:
Conditions works wrong:
|
| Comments |
| Comment by Andrii Nikitin (Inactive) [ 2017-01-25 ] | ||||||||||||||||||||||||||||
|
json column type is not supported in MariaDB yet, so you should receive syntax error while trying to create such table in MariaDB at the moment. Please note that these examples cannot work properly as you can't compare arrays to constants.
My personal belief is that you should avoid processing JSON inside RDBMS - in long run it will bring you more problems than benefits. But if you still sure that you want to do it - the best idea I can think about such task in MariaDB of is to replace 'json' in column definition to 'text' and generate queries like this (if you know maximum number of products per order):
use OR if you need to find products where at least one price is bigger than 50 and AND if you want to make sure that every price is bigger (i.e. compare array to constant). | ||||||||||||||||||||||||||||
| Comment by Andrii [ 2017-01-28 ] | ||||||||||||||||||||||||||||
|
Thank you @Andrii Nikitin for such fast and detailed answer! You are right that RDBMS always was not the best place for JSON, but it looks like Not Only SQL strategy of RDBMS development is on the right course with JSON support and the most way is already passed. |