Comments (1)
Sqlite does not come with a json_contains()
type of function that would work as you describe. You'll need to instead use it's existing operators (extract) or implement a user-defined json_contains()
for that particular operation.
Peewee provides a sample json_contains()
but it does not behave as you described for absent keys in the data.
Simple example:
db = SqliteExtDatabase(':memory:', json_contains=True)
...
q = KV.select().where(fn.json_contains(KV.opt, json.dumps({'k1': 0})))
for row in q:
print(row.value)
# 11.0
# 12.0
q = KV.select().where(fn.json_contains(KV.opt, json.dumps({'k1': 1, 'k2': 999})))
for row in q:
print(row.value)
# no output, since k2 not present in source
So you'll probably want to modify the example json_contains()
user-defined function to behave as you described. The source for it is here:
peewee/playhouse/sqlite_ext.py
Lines 1324 to 1359 in c597250
from peewee.
Related Issues (20)
- Documentation is wrong or not up to date for the creation of objects from model. HOT 4
- Documentation missing for ArrayField. HOT 2
- Documentation is wrong or not up to date for the creation of objects from model. HOT 3
- How to get the length of the CharField data? HOT 1
- The coroutine is canceled HOT 1
- 启动项目后缺少public文件夹导致错误 HOT 1
- Seeking Clarification on wrapped_count() Method in Peewee 3.17.1 HOT 2
- [Question] Performance gain or loss when paginating in full-text search PostgreSQL HOT 1
- [Question] Seeking Guidance on Clause Class Removal in Peewee 3.17.1 HOT 1
- is_null() broken when using psycopg3 HOT 3
- Occasionally triggers full table scan(不定时触发统计全表) HOT 3
- Autofield() defined in a model for an existing table with N rows does not use the latest auto increment value for the primary key HOT 4
- How to mix PooledSqliteDatabase and SqlCipherExtDatabase HOT 3
- Not optimal primary key lookup HOT 2
- Discussion page? HOT 1
- CompositeKey with the single column leads to unexpected error. HOT 3
- how to connect pgsql use sha256 HOT 1
- IDEA missing usage for ForeignKeyField, any annotation can solved? HOT 2
- Error Serializing Foreign Key UUIDs with Psycopg3Database HOT 1
- Support for JSONB in SQLite HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peewee.