# Odd binary id mismatch

**URL:** <https://forum.elixirforum.com/t/odd-binary-id-mismatch/14719>\
**Category:** Questions\
**Tags:** ecto, mysql\
**Created:** [June 17, 2018, 9:19am UTC](https://forum.elixirforum.com/t/odd-binary-id-mismatch/14719 "2018-06-17T09:19:32Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![peerreynders](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/32/5826_2.png) [@peerreynders](https://forum.elixirforum.com/u/peerreynders)\
**Post date:** [June 18, 2018, 2:35pm UTC](https://forum.elixirforum.com/t/odd-binary-id-mismatch/14719/7 "2018-06-18T14:35:07Z")

</div>

Have your tried:

```elixir
  source = %MyModule{} |> Repo.insert!()
  new = Repo.get!(MyModule, source.id)
  new2 = Repo.get!(MyModule, new.id)

  assert new2.id == new.id

```

What is not clear is whether `new` actually originates from the **same record** that was created by the previous `Repo.insert!`. If there are other records in the table, `new` could be an entirely different record.

Some experiments with iEX and the SQL shell could shed some light on that:

- after the insert - is there a record with the new UUID (e.g. `3f3fd9a2-3f69-463e-3f3f-153f34003f3f`)
- after the retrieve - is there a record with the different UUID (e.g. `85c9d9a2-a969-463e-a8d5-15f834009ebc`)
- does the remainder of the retrieved record match the former or the latter record content?

This was never resolved:

> [@Ecto use of UUIDs as foreign keys gives inconsistent query results](https://forum.elixirforum.com/t/ecto-use-of-uuids-as-foreign-keys-gives-inconsistent-query-results/6789):
>
> the following test is failing from time to time: test "successful message creation" do room = Room.changeset(@valid\_room\_attrs, :create) |\> Repo.insert! msg0 = Message.changeset(%Message{}, @valid\_message\_attrs) |\> put\_assoc(:room, room) |\> Repo.insert! msg1 = Message.changeset(%Message{}, @valid\_message\_attrs) |\> put\_assoc(:room, room) |\> Repo.insert! room\_uuid = room.uuid messages = (from msg in Message, where: msg.room\_uuid == ^room.uuid, select: msg, preload: :room) |\> Repo.all …

---

_[View the full topic](https://forum.elixirforum.com/t/odd-binary-id-mismatch/14719)._
