Skip to content

Commit d7c8652

Browse files
authored
fix order of the ismaster command in the case of MongoDB < 4.4 (#147)
1 parent b072422 commit d7c8652

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/mongo/mongo_db_connection.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,18 +410,20 @@ defmodule Mongo.MongoDBConnection do
410410
end
411411

412412
defp handshake_command(%{stable_api: stable_api}, client) do
413-
StableVersion.merge_stable_api([hello: 1, client: client], stable_api)
413+
[client: client]
414+
|> StableVersion.merge_stable_api(stable_api)
415+
|> Keyword.put(:hello, 1)
414416
end
415417

416418
defp hello_command(cmd, %{hello_ok: false}) do
417419
cmd
418-
|> Keyword.put(:ismaster, 1)
419420
|> Keyword.put(:helloOk, true)
421+
|> Keyword.put(:ismaster, 1)
420422
end
421423

422424
defp hello_command(cmd, %{hello_ok: true, stable_api: stable_api}) do
423425
cmd
424-
|> Keyword.put(:hello, 1)
425426
|> StableVersion.merge_stable_api(stable_api)
427+
|> Keyword.put(:hello, 1)
426428
end
427429
end

0 commit comments

Comments
 (0)