So, when get by id:
iex(10)> product = Repo.get(Operator.Product, 610218)
[debug] QUERY OK source="products" db=2.9ms idle=1295.5ms
SELECT p0."id", p0."uid", p0."name", p0."max_production", p0."effective_production", p0."stop_time_min", p0."product_code", p0."barcode", p0."enabled", p0."data", p0."company_id", p0."allowed_workstations", p0."inserted_at", p0."updated_at" FROM "products" AS p0 WHERE (p0."id" = $1) [610218]
%Operator.Product{
__meta__: #Ecto.Schema.Metadata<:loaded, "products">,
id: 610218,
uid: "91985903-2c2e-4002-993b-2c2e72d7e517",
name: "3222312724 | 92608 | OP20 | 5188 | Air receiver - Welding Epiroc light side ",
max_production: 0.025,
effective_production: nil,
stop_time_min: 40.0,
product_code: "3222312724",
barcode: nil,
enabled: 1,
data: nil,
master_product: #Ecto.Association.NotLoaded<association :master_product is not loaded>,
company_id: 513,
company: #Ecto.Association.NotLoaded<association :company is not loaded>,
productions: #Ecto.Association.NotLoaded<association :productions is not loaded>,
production_product: #Ecto.Association.NotLoaded<association :production_product is not loaded>,
production_scraps: #Ecto.Association.NotLoaded<association :production_scraps is not loaded>,
orders: #Ecto.Association.NotLoaded<association :orders is not loaded>,
allowed_workstations: nil,
restricted_to_workstations: #Ecto.Association.NotLoaded<association :restricted_to_workstations is not loaded>,
inserted_at: ~N[2023-09-07 08:44:16],
updated_at: ~N[2023-09-07 08:44:16]
}
And with get_by:
iex(13)> Repo.get_by(Operator.Product, name: product.name)
nil
iex(14)> [debug] QUERY OK source="products" db=70.6ms queue=1.6ms idle=1326.4ms
SELECT p0."id", p0."uid", p0."name", p0."max_production", p0."effective_production", p0."stop_time_min", p0."product_code", p0."barcode", p0."enabled", p0."data", p0."company_id", p0."allowed_workstations", p0."inserted_at", p0."updated_at" FROM "products" AS p0 WHERE (p0."name" = $1) ["3222312724 | 92608 | OP20 | 5188 | Air receiver - Welding Epiroc light side"]
So, as you can see, Repo.get_by actually trimmed the trailing space.
To be sure, I have manually put trailing space on one of the product names and result is the same:
Using Ecto: {:phoenix_ecto, “~> 4.4”},