You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a query like so which I'm passing an array of ids and a string
Repo.all(
from p in Punchcard,
join: sm in assoc(p, :sm),
join: application in assoc(p, :application),
join: profile in assoc(application, :profile),
where: sm.state_id in ^state_ids,
where: profile.country_code == ^country_code,
select: p
)
If I pass a single value array, it works:
Expected Behavior
QUERY OK source="Punchcard" db=144.2ms
SELECT P0."sm_id", P0."application_id", P0."check_in", P0."check_out", P0."amt_to_talent", P0."amt_to_hyr" FROM "Punchcard" AS P0 INNER JOIN "Sm" AS S1 ON (S1."sm_id" = P0."sm_id") INNER JOIN "Application" AS A2 ON (A2."sm_id" = P0."application_id") INNER JOIN "Profile" AS P3 ON (P3."sm_id" = A2."profile_id")
WHERE ((S1."state_id" IN (?)) AND (P3."country_code" = ?)) ORDER BY P0."sm_id" DESC [4202, "US"]
The last part is most relevant. However, as soon as I pass a second item to the array the variable insertion seems to misalign
Actual Behavior
QUERY ERROR source="Punchcard" db=90.2ms queue=20.2ms
SELECT P0."sm_id", P0."application_id", P0."check_in", P0."check_out", P0."amt_to_talent", P0."amt_to_hyr" FROM "Punchcard" AS P0 INNER JOIN "Sm" AS S1 ON (S1."sm_id" = P0."sm_id") INNER JOIN "Application" AS A2 ON (A2."sm_id" = P0."application_id") INNER JOIN "Profile" AS P3 ON (P3."sm_id" = A2."profile_id")
WHERE ((S1."state_id" IN (?,?)) AND (P3."country_code" = ?)) [4202, 4204, "US"]
My database thinks that "US" is being passed to the "state_id" IN(?,?) clause.
Conversion failed when converting the nvarchar value 'US' to data type int. | ODBC_CODE 22018 | SQL_SERVER_CODE 245
Unless I'm missing something, it seems not to be behaving correctly.
Possible Solution
it works to reverse the where clauses
WHERE (P3."country_code" = ?) AND (S1."state_id" IN (?,?,?)) ["US", 4202, 4204, 4303]
Your Environment
latest
The text was updated successfully, but these errors were encountered:
Thanks @shdblowers , those tests look good except for not having the joins. Don't know how that could change the behavior. I can try to apply the same WHERE IN to various other queries and let you know if I see the same error.
I have a query like so which I'm passing an array of ids and a string
If I pass a single value array, it works:
Expected Behavior
The last part is most relevant. However, as soon as I pass a second item to the array the variable insertion seems to misalign
Actual Behavior
My database thinks that "US" is being passed to the "state_id" IN(?,?) clause.
Unless I'm missing something, it seems not to be behaving correctly.
Possible Solution
it works to reverse the where clauses
Your Environment
latest
The text was updated successfully, but these errors were encountered: