Comments (8)
SQL Server: ISJSON SQLite: json_valid MySQL: JSON_VALID PostgreSQL: not needed, since the column type (
jsonb
) already enforces JSON
Oracle: IS JSON
from efcore.checkconstraints.
@molinch yeah, I'm definitely aware of ISJSON - see the above comparison.
from efcore.checkconstraints.
@pietrodicaprio I don't think adding an ISJSON check constraint would improve performance - it would only make sure that only JSON data is ever present in the column (and in fact would hurt performance by doing so). Can you point to where you saw that?
In any case, this plugin is just a shortcut for some common constraints - you can always define your own check constraints yourself.
from efcore.checkconstraints.
@pietrodicaprio I don't think adding an ISJSON check constraint would improve performance - it would only make sure that only JSON data is ever present in the column (and in fact would hurt performance by doing so). Can you point to where you saw that?
In any case, this plugin is just a shortcut for some common constraints - you can always define your own check constraints yourself.
I'm sorry, used wrong wording: I meant they suggest it to improve the processing by, indeed, enabling the check that ensures only JSON data is stored in the column (that is what I'm looking for)
from efcore.checkconstraints.
SQL Server: ISJSON
SQLite: json_valid
MySQL: JSON_VALID
PostgreSQL: not needed, since the column type (jsonb
) already enforces JSON
from efcore.checkconstraints.
@roji I think what might be even more useful is to be able to constraint JSON data as any other data.
For example, you can have a PrimitiveCollection which gets serialized as a JSON array (on SQL Server), but unfortunately you won't receive checked constraints for items in the array.
Example: the collection gets serialized as a JSON array of genders ["male", "female", "other"]. Right now you cannot prevent having "dog" within it.
from efcore.checkconstraints.
@molinch this issue currently on tracks that a column contains valid JSON, not that the values inside a collection are in a specific valid list. How do you propoes we implement your proposal?
from efcore.checkconstraints.
So if you have a PrimitiveCollection then the checked constraint could be as ISJSON(json_col, ARRAY)
(see: https://learn.microsoft.com/en-us/sql/t-sql/functions/isjson-transact-sql?view=sql-server-ver16)
However that would still not validate the content of the array. It would just ensure we do have a JSON array.
In order to go that far I don't see any good solution except writing a user defined function and having a checked constraint calling it ... That seems way beyond what this library should do.
from efcore.checkconstraints.
Related Issues (20)
- Support the new 8.0 validation attributes HOT 3
- The regular expression generated by URLAttribute is insufficient HOT 1
- Doesn't generate any check constraint when targeting a mysql database
- [Request] Implement Required attribute to disallow empty strings HOT 2
- Initial SQL Server regex setup does not work HOT 11
- Range check constraints not generated for some datatype HOT 12
- Feature Request: Support Fluent Configuration with Lambda Expressions HOT 2
- Support [Base64String]
- Check constraint as an expression instead of sql? HOT 2
- Add additional URL protocols to Common Url pattern HOT 2
- Adds unexpected constraints when using together with [Required] attribute HOT 4
- UseEnumCheckConstraints does not respect DbContext conventions
- Use new regex support on Azure SQL HOT 4
- Range check doesn't work for decimals HOT 4
- String Length constraint on owned entity HOT 2
- InvalidOperationException with in-memory DB HOT 6
- Allow lowercase naming, for example `ck` instead of `CK` HOT 8
- feat: Add Constraint for brazilian official info HOT 2
- Don't generate enum constraints for PostgreSQL native enum mapping
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 efcore.checkconstraints.