rwynn / gtm

gtm (go tail mongo) is a MongoDB event listener
MIT License
146 stars 33 forks source link

unset slice occur #27

Open EdwardShen125 opened 2 years ago

EdwardShen125 commented 2 years ago

Mistakes happened when i migrates docs from one table to another. source doc like {"A":[], "B":"name"} result doc like {"B":"name"} that A field was unset when param "a" of func "normalizeDocSlice" was a zero length slice that not nil pointer. So the returned var "avs" was a nil.

i guess var avs = make([]interface{}, 0) may solve my problem

rwynn commented 2 years ago

I'm not sure there is a difference in Elasticsearch between an empty array and a missing field.

https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html

An array may contain null values, which are either replaced by the configured null_value or skipped entirely. An empty array [] is treated as a missing field — a field with no values.

I could be wrong though.

rwynn commented 2 years ago

Sorry, disregard my last comment. I thought this issue was in a different repository.

I just pushed a fix for this and will create a new release for it.

EdwardShen125 commented 2 years ago

Sorry, disregard my last comment. I thought this issue was in a different repository.

I just pushed a fix for this and will create a new release for it.

that's great!