Comments (6)
Yeah, that is an issue :-/
Making a 1 to 1 mapping between SQL and D is a tricky problem, hence I let people like you do it for me :-)
I was thinking however, of having a @CustomConstraint()
UDA, that would be usable like:
struct myStruct{
@PK @serial id;
@CustomConstraint("NOT NULL") string email;
}
The constraint would be added with an ALTER TABLE
call later (similar to how current constraints are added in your ensureSchema
function).
I think that would allow the user to deal with situations like this.
I don't think it'd be overly hard to add either, hopefully I'll get time to experiment with it soon.
Edit: The reason I think a @CustomConstraint
may be easier than implementing a @NotNullable
is that it's quite obvious to the programmer that what your doing is something custom that isn't handled normally by dpq, and thus you need to take special care here.
from dpq.
I'll look into it in the coming days, thanks for the input. :)
from dpq.
You're correct, there is currently no way to specify NOT NULL
with dpq.
Implementing support for it through @notNullable
or similar should not be an issue, but there is however, the issue of what values can actually be nullable according to D. Scalar values cannot be nullable and need to be specified so using the Nullable template, same goes for structs, but not classes or other heap-allocated resources.
Does this mean we should simply assume all D scalar values to be NOT NULL
? I'm not sure I want to make such assumptions.
from dpq.
Also @grogancolin's idea of CustomConstraint may help to deal with other SQL constraints like CHECK (price > 0)
, etc
from dpq.
Thanks @IrenejMarc !
from dpq.
v0.8.7 adds support for this https://github.com/IrenejMarc/dpq/releases/tag/v0.8.7
No full constraint support for now, since those would have to operate on a tables themselves, not columns and I can't think of a way to make that look nice right now :)
from dpq.
Related Issues (20)
- DPQ doesn't throw when you try connecting to port 0
- Add support for serializing BigInt to NUMERIC HOT 5
- Support for JSON Fields HOT 6
- Turn off camelCase to underscore_pg HOT 3
- Explicit connection or ProxyMixin. HOT 1
- RelationProxy reset query HOT 2
- Deprecation with dmd 2.078
- code.dlang not updated HOT 2
- Conversion issue
- Deprecation on test HOT 1
- Deprecation with dmd 2.096 HOT 3
- DateTime deserialization is not correct HOT 1
- Deprecations
- Noisy Writes to Stdout HOT 1
- _dpqLastConnection is not visible from module HOT 2
- IsValidRelation returns false for a relation declared without explicit name
- Result iteration issues HOT 2
- RelationProxy on structs containing Nullable!SysTime causes compilation error.
- Use on windows HOT 1
- deprecation with dmd 100
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 dpq.