Closed roback closed 5 years ago
This is something we would need in https://github.com/twingly/zambezi/blob/466b2bbe307a9362eccd2a22aae6e385b8843ee7/script/lib/queue_documents.rb#L168-L175
For example, if you want to publish the message
[["1", "2"],["3", "4"]]
as JSON you would end up with{"1":"2","3":"4"}
which may not be what you would expect.
I previously failed to notice that we have some tests that ensure that arrays gets converted to hashes, so this isn't really unexpected behaviour :)
Not closed in #73 (I accidentally wrote "fix" before the issue number in the PR description 🤦♂️ )
The problem is that Array responds to
#to_h
: https://github.com/twingly/twingly-amqp/blob/f0484795f528822f158df3314eb218df25de9379/lib/twingly/amqp/default_exchange_publisher.rb#L15-L21For example, if you want to publish the message
[["1", "2"],["3", "4"]]
as JSON you would end up with{"1":"2","3":"4"}
which may not be what you would expect.Trying to publish a message with the following structure
[{type: "insert"},{type: "update"}]
just raises an error:twingly/amqp/default_exchange_publisher.rb:18:in 'to_h': wrong element type Hash at 0 (expected array) (TypeError)
.Same problem in both publisher classes (DefaultExchangePublisher, TopicExchangePublisher).