-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #12990 -- Added JSONField model field. #11452
Conversation
1f8b5c7
to
8110513
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It is also not a separate field on Oracle, but a feature flag will determine if backend has JSON field or not, so ... 🤔 |
This comment has been minimized.
This comment has been minimized.
Thanks! As expected, the tests have passed now. I have added a Also, I'm not sure if I should use |
7433b52
to
3f9c68d
Compare
I've added a form field. It's pretty much the one in |
I think trying the The other option is to use
|
I'm not sure where and how to properly put it in Django's source code, though. I tried compiling SQLite 3.28.0 without JSON1, compiling JSON1 separately, and loading it with the On the other hand, I also tried loading JSON1 (compiled from SQLite 3.28.0 source code) on SQLite 3.8.7.1 (what's available on Debian Jessie). This SQLite version supports extension loading, but I got a segmentation fault when I tried to load JSON1. So, I guess it needs SQLite 3.9.0 and up. By the way... JSON1 is also enabled by default if SQLite is compiled using |
You can use a |
Yeah, I've used it in my try:
with self.connection.cursor() as cursor:
cursor.execute("SELECT JSON('\"test\"')
except DatabaseError:
return False
else:
return True |
That looks like what I was thinking of, though you might need a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice 👍 I left some comments.
71305bd
to
0590edb
Compare
@felixxm If you're aiming to simplify Oracle implementation, we can try using the dot notation syntax to access JSON values, instead of using |
2fc7eb7
to
fafbc3c
Compare
Added documentation and tests for the system check.
…transform(lookup='value__baz__contained_by') on MySQL, MariaDB, and SQLite. We need to also swap params not only sides of expressions.
…transform(lookup='value__baz__contained_by') on MySQL, MariaDB, and SQLite. We didn't handle how the lhs and rhs can be instances of KeyTransform/KeyTextTransform
It's not possible in PostgreSQL, and it's already represented by value__baz__has_keys
It's a subclass of KeyTransform
…te and removed unused models.
The logic should belong to the KeyTransform itself
8f4716e
to
7f7e1a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @laymonage. Time to move this forward. 🙂
- Can you squash as of 7f7e1a1, and open a fresh PR at that point.
- Any changes after 7f7e1a1 to be in separate commits for now (to help us continue the review). We'll squash down again later on.
I will then ask for testing from the community. Folks can comment with any regressions/issues on the fresh PR, and we can get those resolved.
I left a few smaller remarks here but I want to look more at the docs and test coverage. I know @felixxm has more comments too. But my overall impression was that it makes sense (and it works on Windows—where those SQLite instructions are necessary—so... 🙂) Good job!
Closing this in favor of #12392. |
This pull request is closed. Please look at #12392 instead.
Ticket #12990, as part of the Google Summer of Code program.
Some points:
Note: Oracle only supports JSON object and array if
IS JSON
constraint is enabled.json.JSONEncoder
andjson.JSONDecoder
, respectively). I had to cast theSELECT
query totext
for PostgreSQL to avoid having the value already decoded infrom_db_value
so it's possible to use a custom decoder (see psycopg2 docs).contrib.postgres.fields.JSONField
are implemented as possibly supported for each backend.JSON_VALID
function which works well.IS JSON
constraint, but from what I tried, it only returns true if the field's value is either a JSON object or array.jsonb
andjson
columns.nclob
data type. Oracle recommends usingblob
, but there are some downsides (see docs). Besides, an existing implementation of oracle-json-field usesclob
.TextField
also usesnclob
, so I think this makes sense.More details of this available on my blog.