Fragment constant/1 doesn't need adapter#4696
Merged
greg-rychlewski merged 1 commit intoelixir-ecto:masterfrom Jan 9, 2026
Merged
Fragment constant/1 doesn't need adapter#4696greg-rychlewski merged 1 commit intoelixir-ecto:masterfrom
greg-rychlewski merged 1 commit intoelixir-ecto:masterfrom
Conversation
josevalim
approved these changes
Jan 9, 2026
Member
Author
|
The integration test failure is related to TDS and how the adapter was handling The failure: * | 1) test fragments (Ecto.Adapters.TdsTest)
+integration-test *failed* | test/ecto/adapters/tds_test.exs:690
+integration-test *failed* | Assertion with == failed
+integration-test *failed* | code: assert all(query) == ~s"SELECT 'let''s escape' FROM [schema] AS s0"
+integration-test *failed* | left: "SELECT N'let''s escape' FROM [schema] AS s0"
+integration-test *failed* | right: "SELECT 'let''s escape' FROM [schema] AS s0"The reason is because string literals are injected this way: defp expr(string, _sources, _query) when is_binary(string) do
"N'#{escape_string(string)}'"
endBut defp expr({:constant, _, [literal]}, _sources, _query) when is_binary(literal) do
[?', escape_string(literal), ?']
endI can fix the test in the an ecto sql pr |
Member
|
Sounds good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now we are passing
{:constant, [], [value]}to the adapter and the adapter is taking care of the unpacking. But we can pass the constant value directly from Ecto and the existing adapter functionality can take care of it without the need for handling a:constanttuple.