null

Remove all null values

北城余情 提交于 2019-12-21 05:46:08
问题 I am trying to remove null values from a json object using jq. I found this issue on their github and so now I'm trying to remove them with del . I have this: '{ id: $customerId, name, phones: ([{ original: .phone }, { original: .otherPhone}]), email} | del(. | nulls)' This doesn't seem to do anything. However if I replace nulls with .phones it does remove the phone numbers. 回答1: The following illustrates how to remove all the null-valued keys from a JSON object: jq -n '{"a":1, "b": null, "c"

Entity framework returns null for a row if the first column in that row is null

落花浮王杯 提交于 2019-12-21 04:41:54
问题 I'm seeing a weird behavior in my Entity Framework model. I've got a query that looks like this: var rows = ( from alarm in context.Alarms join temp in context.ListDetails on alarm.ListDetailId equals temp.ListDetailId into entries from entry in entries.DefaultIfEmpty() join read in context.Reads on alarm.ReadId equals read.ReadId join plate in context.Images on alarm.ReadId equals plate.ReadId where alarm.IActive == 1 && ! alarm.TransmittedAlarm where read.IActive == 1 where plate.IActive ==

C++ string that can be NULL

余生颓废 提交于 2019-12-21 04:31:16
问题 I'm used to passing around string like this in my C++ applications: void foo(const std::string& input) { std::cout << input.size() << std::endl; } void bar() { foo("stackoverflow"); } Now I have a case where I want the string to be NULL: void baz() { foo("stackoverflow"); foo(NULL); // very bad with foo implementation above } I could change foo to: void foo(const std::string* input) { // TODO: support NULL input std::cout << input->size() << std::endl; } But to pass a string literal or copy a

C++ string that can be NULL

狂风中的少年 提交于 2019-12-21 04:31:14
问题 I'm used to passing around string like this in my C++ applications: void foo(const std::string& input) { std::cout << input.size() << std::endl; } void bar() { foo("stackoverflow"); } Now I have a case where I want the string to be NULL: void baz() { foo("stackoverflow"); foo(NULL); // very bad with foo implementation above } I could change foo to: void foo(const std::string* input) { // TODO: support NULL input std::cout << input->size() << std::endl; } But to pass a string literal or copy a

Nils and method chaining

时间秒杀一切 提交于 2019-12-21 04:06:54
问题 I'm just breaking into the ruby world and I could use a helping hand. Suppose b is nil . I'd like the following code to return nil instead of a "NoMethodError: undefined method" a.b.c("d").e The first thing I tried was to overload NilClass's missing_method to simply return a nil. This is the behaviour I want except I don't want to be this intrusive. I'd love it if I could do something like this SafeNils.a.b.c("d").e So it's like a clean way to locally overload the NilClass's behaviour. I'd

optional array in avro schema

南楼画角 提交于 2019-12-21 03:52:52
问题 I'm wondering whether or not it is possible to have an optional array. Let's assume a schema like this: { "type": "record", "name": "test_avro", "fields" : [ {"name": "test_field_1", "type": "long"}, {"name": "subrecord", "type": [{ "type": "record", "name": "subrecord_type", "fields":[{"name":"field_1", "type":"long"}] },"null"] }, {"name": "simple_array", "type":{ "type": "array", "items": "string" } } ] } Trying to write an avro record without "simple_array" would result in a NPE in the

Will isset() return false if I assign NULL to a variable?

好久不见. 提交于 2019-12-21 03:51:16
问题 I mean... I "set" it to NULL. So isset($somethingNULL) == true? 回答1: bool isset ( mixed $var [, mixed $var [, $... ]] ) Determine if a variable is set and is not NULL. If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL . Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant. Return values Returns TRUE if var exists and has value other than NULL, FALSE otherwise. From the manual.

Check array position for null/empty

混江龙づ霸主 提交于 2019-12-21 03:43:10
问题 I have an array which might contain empty/null positions (e.g: array[2]=3, array[4]=empty/unassigned). I want to check in a loop whether the array position is null. array[4]==NULL //this doesn't work I'm pretty new to C++. Thanks. Edit: Here's more code; A header file contains the following declaration int y[50]; The population of the array is done in another class, geoGraph.y[x] = nums[x]; The array should be checked for null in the following code; int x=0; for(int i=0; i<sizeof(y);i++){ /

C# Database Access: DBNull vs null

跟風遠走 提交于 2019-12-21 03:36:33
问题 We have our own ORM we use here, and provide strongly typed wrappers for all of our db tables. We also allow weakly typed ad-hoc SQL to be executed, but these queries still go through the same class for getting values out of a data reader. In tweaking that class to work with Oracle, we've come across an interesting question. Is it better to use DBNull.Value, or null? Are there any benefits to using DBNull.Value? It seems more "correct" to use null, since we've separated ourselves from the DB

AVL树的删除

冷暖自知 提交于 2019-12-21 02:35:23
本文默认不讲左右旋转和左右结点失衡,总共六种情况的处理 先是AVL树的定义 typedef struct BSTNode { ElemType data; int bf; struct BSTNode* lchild, * rchild; }BSTNode, *BSTree; 然后是左右旋转 void R_Rotate(BSTree& p) { BSTree lc = p->lchild; p->lchild = lc->rchild; lc->rchild = p; p = lc; } void L_Rotate(BSTree& p) { BSTree rc = p->rchild; p->rchild = rc->lchild; rc->lchild = p; p = rc; } 然后是对左结点和右结点做平衡 void LeftBalance(BSTree& T) { BSTree lc = T->lchild; switch (lc->bf) { case EH: { T->bf = LH; lc->bf = RH; R_Rotate(T); break; } case LH: { T->bf = lc->bf = EH; R_Rotate(T); break; } case RH: { BSTree rd = lc->rchild; switch (rd->bf) {