OHMySQL
OHMySQL copied to clipboard
INSERT with NSNull.null inserts a zero into an optional Int field rather than NULL
What did you do?
Issued an INSERT with an NSNull.null value for an INT field.
What happened instead?
A zero value was inserted into the INT field rather than NULL. Note that the field allows for NULL values.
What did you expect?
I expected the field to contain NULL (no value).
OHMySQL Environment
- OHMySQL version: 2.1.3 (March 2018)
- Xcode version: 9.2
- Swift version: (if applicable, if not remove)
- Platform(s) running OHMySQL: OSX 10.13.3
Demo Project
Don't have a demo project yet. The INSERT code is pretty simple:
NSDictionary<NSString*, id> *d = [NSDictionary dictionaryWithObjectsAndKeys: "Bob", @"user", [NSDate date], @"modified", NSNull.null, @"rec_no", nil];
OHMySQLQueryRequest *request = [OHMySQLQueryRequestFactory INSERT:@"Log" set:d];
and then passed the request to an OHMySQLQueryContext.
Thanks for good report.