Ecto: dynamic fragment from runtime valuesSave PL/pgSQL output from PostgreSQL to a CSV fileHow to exit from PostgreSQL command line utility: psqlHow to configure Ecto at runtime?Building Dynamic fragments in Ectodynamic ecto select with several fragmentHow to use date_trunc with timezone in Ecto fragment statementHow to update field value dynamically in Ecto migration?Dynamically selecting map Ectoecto fragment as query sourceorder_by with dynamic value on Ecto
In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?
Past vs. present tense when referring to a fictional character
Jam with honey & without pectin has a saucy consistency always
Does every chapter have to "blow the reader away" so to speak?
Do Veracrypt encrypted volumes have any kind of brute force protection?
Shouldn't it take more energy to break CO2 compared to CO?
Why is my Taiyaki (Cake that looks like a fish) too hard and dry?
How to represent jealousy in a cute way?
Is there a term for someone whose preferred policies are a mix of Left and Right?
Placement of positioning lights on A320 winglets
What publication claimed that Michael Jackson died in a nuclear holocaust?
My parents claim they cannot pay for my college education; what are my options?
What do you call the action of "describing events as they happen" like sports anchors do?
typeid("") != typeid(const char*)
Does "aurea" have the second meaning?
Is all-caps blackletter no longer taboo?
Arrows inside a commutative diagram using tikzcd
Dedicated bike GPS computer over smartphone
Can artificial satellite positions affect tides?
Would a bit of grease on overhead door cables or bearings cause the springs to break?
What game uses dice with compass point arrows, forbidden signs, explosions, arrows and targeting reticles?
Approach sick days in feedback meeting
Is it true that "only photographers care about noise"?
Print the phrase "And she said, 'But that's his.'" using only the alphabet
Ecto: dynamic fragment from runtime values
Save PL/pgSQL output from PostgreSQL to a CSV fileHow to exit from PostgreSQL command line utility: psqlHow to configure Ecto at runtime?Building Dynamic fragments in Ectodynamic ecto select with several fragmentHow to use date_trunc with timezone in Ecto fragment statementHow to update field value dynamically in Ecto migration?Dynamically selecting map Ectoecto fragment as query sourceorder_by with dynamic value on Ecto
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm building an API that allows the end-user to specify the sort on a list of data, returning paginated results. For example, an API request might specify a sort of name: :asc, id: :asc
, or age: :desc, id: :desc
. In the implementation, I'm trying to use the row-value syntax for selecting subsequent pages from an existing Ecto query.
In Rails, this is easy — just interpolate a string and splat some arguments:
# @param [ActiveRecord::Relation] rel
def slice_query(rel, cursor_params)
# A little hand-waving
operator, comparisons = parse_params(cursor_params)
# Suppose `operator` is `<` and comparisons looks like `name: "Last Row Value", id: "last-row-value"
fragment = "(#comparisons.keys.join(',')) #operator (#comparisons.size.times.map '?' .join(','))"
# fragment in this case should look like "(name, id) < (?, ?)"
rel.where(fragment, *comparisons.values)
end
As an Ecto/Elixir newbie, I'm at a loss for how to do this with Ecto. The docs seem to indicate that custom fragments can be implemented via macros, but I'm at a loss for how to dynamically interpolate runtime values into a macro-based implementation.
I've tried something like this:
def slice_query(query, cursor_params)
# More hand-waving; `parse_params` is a bit of pseudocode.
# Full source is below
operator, comparisons = parse_params(cursor_params)
query |> where(row_value_comparison(operator, comparisons)
end
In particular, operator
is a binary string, and comparisons
is the result of an Enum.map
.
Using row_value_comparison
from here, but I've run into various compiler complaints depending on how I interpolate (or don't interpolate) operator
and comparisons
into that macro invocation:
query |> where(row_value_comparison(operator, comparisons)
yieldsprotocol Enumerable not implemented for :comparisons, [line: 114], nil
query |> where(row_value_comparison(operator, ^comparisons)
yieldsprotocol Enumerable not implemented for :^, [line: 114], [:comparisons, [line: 114], nil]
query |> where(row_value_comparison(operator, unquote(comparisons)))
yieldsvariable "comparisons" does not exist and is being expanded to "comparisons()", please use parentheses to remove the ambiguity or change the variable name
query |> where(row_value_comparison(comparator, unquote(^comparisons)))
yieldscannot use ^comparisons outside of match clauses
Full module source, as requested in comments:
defmodule MyProject.Resolvers.Connection do
import Ecto.Query
alias MyProject.Repo
# `cursor_params` should be a Map containing either
# :after (and optionally :first) (to paginate forward), or
# :before (and optionally :last) (to paginate backwards).
# :after or :before should be parsed Cursors.
#
# This method implements ApplyCursorsToEdges according to the spec:
# https://facebook.github.io/relay/graphql/connections.htm#sec-Arguments
def paginate_with_results(query, cursor_params) do
total_count = query_count(query)
query = slice_query(query, cursor_params)
has_previous_page, has_next_page = query_page_info(query, cursor_params)
query = limit_results(query, cursor_params)
%
results: Repo.all(query),
page_info: %
total_count: total_count,
has_next_page: has_next_page,
has_previous_page: has_previous_page
end
defp order_bys(query) do
query.order_bys
|> Enum.map(fn %Ecto.Query.QueryExprexpr: expr ->
expr
|> Enum.map(fn dir, ast ->
> Macro.to_string()
end)
end)
|> List.first()
end
defp single_sort_direction?(query) do
directions = order_bys(query) |> Enum.map(fn dir, _ -> dir end) |> Enum.uniq()
if Enum.count(directions) == 1, do: Enum.at(directions, 0), else: false
end
defp query_count(query) do
query |> select([x], count(x.id)) |> Repo.one()
end
# https://elixirforum.com/t/building-an-ecto-macro-to-generate-a-row-value/19680/2
defmacro row_value_comparison(operation, comparisons) do
# when is_binary(operation) and is_list(comparisons) do
question_marks = Enum.map(comparisons, fn _ -> "?" end) |> Enum.join(", ")
frag_text = "(#question_marks) #operation (#question_marks)"
frag_arguments =
comparisons
|> Enum.unzip()
|> Tuple.to_list()
|> List.flatten()
quote do
fragment(unquote(frag_text), unquote_splicing(frag_arguments))
end
end
defp slice_query(query, cursor_params) do
sort_descriptors = order_bys(query)
query =
if Map.has_key?(cursor_params, :after) do
after_cursor = cursor_params.after
if direction = single_sort_direction?(query) do
comparator = if direction == :asc, do: ">", else: "<"
comparisons =
Enum.map(sort_descriptors, fn _dir, field ->
field, after_cursor.sort_values[field]
end)
query |> where(row_value_comparison(comparator, unquote(comparisons)))
else
# TODO: Handle multi-direction sort
query
end
end
# Etc
end
end
postgresql elixir ecto
add a comment |
I'm building an API that allows the end-user to specify the sort on a list of data, returning paginated results. For example, an API request might specify a sort of name: :asc, id: :asc
, or age: :desc, id: :desc
. In the implementation, I'm trying to use the row-value syntax for selecting subsequent pages from an existing Ecto query.
In Rails, this is easy — just interpolate a string and splat some arguments:
# @param [ActiveRecord::Relation] rel
def slice_query(rel, cursor_params)
# A little hand-waving
operator, comparisons = parse_params(cursor_params)
# Suppose `operator` is `<` and comparisons looks like `name: "Last Row Value", id: "last-row-value"
fragment = "(#comparisons.keys.join(',')) #operator (#comparisons.size.times.map '?' .join(','))"
# fragment in this case should look like "(name, id) < (?, ?)"
rel.where(fragment, *comparisons.values)
end
As an Ecto/Elixir newbie, I'm at a loss for how to do this with Ecto. The docs seem to indicate that custom fragments can be implemented via macros, but I'm at a loss for how to dynamically interpolate runtime values into a macro-based implementation.
I've tried something like this:
def slice_query(query, cursor_params)
# More hand-waving; `parse_params` is a bit of pseudocode.
# Full source is below
operator, comparisons = parse_params(cursor_params)
query |> where(row_value_comparison(operator, comparisons)
end
In particular, operator
is a binary string, and comparisons
is the result of an Enum.map
.
Using row_value_comparison
from here, but I've run into various compiler complaints depending on how I interpolate (or don't interpolate) operator
and comparisons
into that macro invocation:
query |> where(row_value_comparison(operator, comparisons)
yieldsprotocol Enumerable not implemented for :comparisons, [line: 114], nil
query |> where(row_value_comparison(operator, ^comparisons)
yieldsprotocol Enumerable not implemented for :^, [line: 114], [:comparisons, [line: 114], nil]
query |> where(row_value_comparison(operator, unquote(comparisons)))
yieldsvariable "comparisons" does not exist and is being expanded to "comparisons()", please use parentheses to remove the ambiguity or change the variable name
query |> where(row_value_comparison(comparator, unquote(^comparisons)))
yieldscannot use ^comparisons outside of match clauses
Full module source, as requested in comments:
defmodule MyProject.Resolvers.Connection do
import Ecto.Query
alias MyProject.Repo
# `cursor_params` should be a Map containing either
# :after (and optionally :first) (to paginate forward), or
# :before (and optionally :last) (to paginate backwards).
# :after or :before should be parsed Cursors.
#
# This method implements ApplyCursorsToEdges according to the spec:
# https://facebook.github.io/relay/graphql/connections.htm#sec-Arguments
def paginate_with_results(query, cursor_params) do
total_count = query_count(query)
query = slice_query(query, cursor_params)
has_previous_page, has_next_page = query_page_info(query, cursor_params)
query = limit_results(query, cursor_params)
%
results: Repo.all(query),
page_info: %
total_count: total_count,
has_next_page: has_next_page,
has_previous_page: has_previous_page
end
defp order_bys(query) do
query.order_bys
|> Enum.map(fn %Ecto.Query.QueryExprexpr: expr ->
expr
|> Enum.map(fn dir, ast ->
> Macro.to_string()
end)
end)
|> List.first()
end
defp single_sort_direction?(query) do
directions = order_bys(query) |> Enum.map(fn dir, _ -> dir end) |> Enum.uniq()
if Enum.count(directions) == 1, do: Enum.at(directions, 0), else: false
end
defp query_count(query) do
query |> select([x], count(x.id)) |> Repo.one()
end
# https://elixirforum.com/t/building-an-ecto-macro-to-generate-a-row-value/19680/2
defmacro row_value_comparison(operation, comparisons) do
# when is_binary(operation) and is_list(comparisons) do
question_marks = Enum.map(comparisons, fn _ -> "?" end) |> Enum.join(", ")
frag_text = "(#question_marks) #operation (#question_marks)"
frag_arguments =
comparisons
|> Enum.unzip()
|> Tuple.to_list()
|> List.flatten()
quote do
fragment(unquote(frag_text), unquote_splicing(frag_arguments))
end
end
defp slice_query(query, cursor_params) do
sort_descriptors = order_bys(query)
query =
if Map.has_key?(cursor_params, :after) do
after_cursor = cursor_params.after
if direction = single_sort_direction?(query) do
comparator = if direction == :asc, do: ">", else: "<"
comparisons =
Enum.map(sort_descriptors, fn _dir, field ->
field, after_cursor.sort_values[field]
end)
query |> where(row_value_comparison(comparator, unquote(comparisons)))
else
# TODO: Handle multi-direction sort
query
end
end
# Etc
end
end
postgresql elixir ecto
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Also,operator, comparisons = ...
is not a valid Elixir match.
– Aleksei Matiushkin
Mar 25 at 6:55
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
Show also either theparse_params
or the content ofcomparisons
.
– Aleksei Matiushkin
Mar 25 at 13:56
@AlekseiMatiushkin sure, I've added all the relevant code from the module.parse_params
was a bit of pseudo-code. Thanks again!
– FeifanZ
Mar 25 at 14:04
add a comment |
I'm building an API that allows the end-user to specify the sort on a list of data, returning paginated results. For example, an API request might specify a sort of name: :asc, id: :asc
, or age: :desc, id: :desc
. In the implementation, I'm trying to use the row-value syntax for selecting subsequent pages from an existing Ecto query.
In Rails, this is easy — just interpolate a string and splat some arguments:
# @param [ActiveRecord::Relation] rel
def slice_query(rel, cursor_params)
# A little hand-waving
operator, comparisons = parse_params(cursor_params)
# Suppose `operator` is `<` and comparisons looks like `name: "Last Row Value", id: "last-row-value"
fragment = "(#comparisons.keys.join(',')) #operator (#comparisons.size.times.map '?' .join(','))"
# fragment in this case should look like "(name, id) < (?, ?)"
rel.where(fragment, *comparisons.values)
end
As an Ecto/Elixir newbie, I'm at a loss for how to do this with Ecto. The docs seem to indicate that custom fragments can be implemented via macros, but I'm at a loss for how to dynamically interpolate runtime values into a macro-based implementation.
I've tried something like this:
def slice_query(query, cursor_params)
# More hand-waving; `parse_params` is a bit of pseudocode.
# Full source is below
operator, comparisons = parse_params(cursor_params)
query |> where(row_value_comparison(operator, comparisons)
end
In particular, operator
is a binary string, and comparisons
is the result of an Enum.map
.
Using row_value_comparison
from here, but I've run into various compiler complaints depending on how I interpolate (or don't interpolate) operator
and comparisons
into that macro invocation:
query |> where(row_value_comparison(operator, comparisons)
yieldsprotocol Enumerable not implemented for :comparisons, [line: 114], nil
query |> where(row_value_comparison(operator, ^comparisons)
yieldsprotocol Enumerable not implemented for :^, [line: 114], [:comparisons, [line: 114], nil]
query |> where(row_value_comparison(operator, unquote(comparisons)))
yieldsvariable "comparisons" does not exist and is being expanded to "comparisons()", please use parentheses to remove the ambiguity or change the variable name
query |> where(row_value_comparison(comparator, unquote(^comparisons)))
yieldscannot use ^comparisons outside of match clauses
Full module source, as requested in comments:
defmodule MyProject.Resolvers.Connection do
import Ecto.Query
alias MyProject.Repo
# `cursor_params` should be a Map containing either
# :after (and optionally :first) (to paginate forward), or
# :before (and optionally :last) (to paginate backwards).
# :after or :before should be parsed Cursors.
#
# This method implements ApplyCursorsToEdges according to the spec:
# https://facebook.github.io/relay/graphql/connections.htm#sec-Arguments
def paginate_with_results(query, cursor_params) do
total_count = query_count(query)
query = slice_query(query, cursor_params)
has_previous_page, has_next_page = query_page_info(query, cursor_params)
query = limit_results(query, cursor_params)
%
results: Repo.all(query),
page_info: %
total_count: total_count,
has_next_page: has_next_page,
has_previous_page: has_previous_page
end
defp order_bys(query) do
query.order_bys
|> Enum.map(fn %Ecto.Query.QueryExprexpr: expr ->
expr
|> Enum.map(fn dir, ast ->
> Macro.to_string()
end)
end)
|> List.first()
end
defp single_sort_direction?(query) do
directions = order_bys(query) |> Enum.map(fn dir, _ -> dir end) |> Enum.uniq()
if Enum.count(directions) == 1, do: Enum.at(directions, 0), else: false
end
defp query_count(query) do
query |> select([x], count(x.id)) |> Repo.one()
end
# https://elixirforum.com/t/building-an-ecto-macro-to-generate-a-row-value/19680/2
defmacro row_value_comparison(operation, comparisons) do
# when is_binary(operation) and is_list(comparisons) do
question_marks = Enum.map(comparisons, fn _ -> "?" end) |> Enum.join(", ")
frag_text = "(#question_marks) #operation (#question_marks)"
frag_arguments =
comparisons
|> Enum.unzip()
|> Tuple.to_list()
|> List.flatten()
quote do
fragment(unquote(frag_text), unquote_splicing(frag_arguments))
end
end
defp slice_query(query, cursor_params) do
sort_descriptors = order_bys(query)
query =
if Map.has_key?(cursor_params, :after) do
after_cursor = cursor_params.after
if direction = single_sort_direction?(query) do
comparator = if direction == :asc, do: ">", else: "<"
comparisons =
Enum.map(sort_descriptors, fn _dir, field ->
field, after_cursor.sort_values[field]
end)
query |> where(row_value_comparison(comparator, unquote(comparisons)))
else
# TODO: Handle multi-direction sort
query
end
end
# Etc
end
end
postgresql elixir ecto
I'm building an API that allows the end-user to specify the sort on a list of data, returning paginated results. For example, an API request might specify a sort of name: :asc, id: :asc
, or age: :desc, id: :desc
. In the implementation, I'm trying to use the row-value syntax for selecting subsequent pages from an existing Ecto query.
In Rails, this is easy — just interpolate a string and splat some arguments:
# @param [ActiveRecord::Relation] rel
def slice_query(rel, cursor_params)
# A little hand-waving
operator, comparisons = parse_params(cursor_params)
# Suppose `operator` is `<` and comparisons looks like `name: "Last Row Value", id: "last-row-value"
fragment = "(#comparisons.keys.join(',')) #operator (#comparisons.size.times.map '?' .join(','))"
# fragment in this case should look like "(name, id) < (?, ?)"
rel.where(fragment, *comparisons.values)
end
As an Ecto/Elixir newbie, I'm at a loss for how to do this with Ecto. The docs seem to indicate that custom fragments can be implemented via macros, but I'm at a loss for how to dynamically interpolate runtime values into a macro-based implementation.
I've tried something like this:
def slice_query(query, cursor_params)
# More hand-waving; `parse_params` is a bit of pseudocode.
# Full source is below
operator, comparisons = parse_params(cursor_params)
query |> where(row_value_comparison(operator, comparisons)
end
In particular, operator
is a binary string, and comparisons
is the result of an Enum.map
.
Using row_value_comparison
from here, but I've run into various compiler complaints depending on how I interpolate (or don't interpolate) operator
and comparisons
into that macro invocation:
query |> where(row_value_comparison(operator, comparisons)
yieldsprotocol Enumerable not implemented for :comparisons, [line: 114], nil
query |> where(row_value_comparison(operator, ^comparisons)
yieldsprotocol Enumerable not implemented for :^, [line: 114], [:comparisons, [line: 114], nil]
query |> where(row_value_comparison(operator, unquote(comparisons)))
yieldsvariable "comparisons" does not exist and is being expanded to "comparisons()", please use parentheses to remove the ambiguity or change the variable name
query |> where(row_value_comparison(comparator, unquote(^comparisons)))
yieldscannot use ^comparisons outside of match clauses
Full module source, as requested in comments:
defmodule MyProject.Resolvers.Connection do
import Ecto.Query
alias MyProject.Repo
# `cursor_params` should be a Map containing either
# :after (and optionally :first) (to paginate forward), or
# :before (and optionally :last) (to paginate backwards).
# :after or :before should be parsed Cursors.
#
# This method implements ApplyCursorsToEdges according to the spec:
# https://facebook.github.io/relay/graphql/connections.htm#sec-Arguments
def paginate_with_results(query, cursor_params) do
total_count = query_count(query)
query = slice_query(query, cursor_params)
has_previous_page, has_next_page = query_page_info(query, cursor_params)
query = limit_results(query, cursor_params)
%
results: Repo.all(query),
page_info: %
total_count: total_count,
has_next_page: has_next_page,
has_previous_page: has_previous_page
end
defp order_bys(query) do
query.order_bys
|> Enum.map(fn %Ecto.Query.QueryExprexpr: expr ->
expr
|> Enum.map(fn dir, ast ->
> Macro.to_string()
end)
end)
|> List.first()
end
defp single_sort_direction?(query) do
directions = order_bys(query) |> Enum.map(fn dir, _ -> dir end) |> Enum.uniq()
if Enum.count(directions) == 1, do: Enum.at(directions, 0), else: false
end
defp query_count(query) do
query |> select([x], count(x.id)) |> Repo.one()
end
# https://elixirforum.com/t/building-an-ecto-macro-to-generate-a-row-value/19680/2
defmacro row_value_comparison(operation, comparisons) do
# when is_binary(operation) and is_list(comparisons) do
question_marks = Enum.map(comparisons, fn _ -> "?" end) |> Enum.join(", ")
frag_text = "(#question_marks) #operation (#question_marks)"
frag_arguments =
comparisons
|> Enum.unzip()
|> Tuple.to_list()
|> List.flatten()
quote do
fragment(unquote(frag_text), unquote_splicing(frag_arguments))
end
end
defp slice_query(query, cursor_params) do
sort_descriptors = order_bys(query)
query =
if Map.has_key?(cursor_params, :after) do
after_cursor = cursor_params.after
if direction = single_sort_direction?(query) do
comparator = if direction == :asc, do: ">", else: "<"
comparisons =
Enum.map(sort_descriptors, fn _dir, field ->
field, after_cursor.sort_values[field]
end)
query |> where(row_value_comparison(comparator, unquote(comparisons)))
else
# TODO: Handle multi-direction sort
query
end
end
# Etc
end
end
postgresql elixir ecto
postgresql elixir ecto
edited Mar 25 at 14:03
FeifanZ
asked Mar 25 at 1:22
FeifanZFeifanZ
14.9k63876
14.9k63876
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Also,operator, comparisons = ...
is not a valid Elixir match.
– Aleksei Matiushkin
Mar 25 at 6:55
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
Show also either theparse_params
or the content ofcomparisons
.
– Aleksei Matiushkin
Mar 25 at 13:56
@AlekseiMatiushkin sure, I've added all the relevant code from the module.parse_params
was a bit of pseudo-code. Thanks again!
– FeifanZ
Mar 25 at 14:04
add a comment |
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Also,operator, comparisons = ...
is not a valid Elixir match.
– Aleksei Matiushkin
Mar 25 at 6:55
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
Show also either theparse_params
or the content ofcomparisons
.
– Aleksei Matiushkin
Mar 25 at 13:56
@AlekseiMatiushkin sure, I've added all the relevant code from the module.parse_params
was a bit of pseudo-code. Thanks again!
– FeifanZ
Mar 25 at 14:04
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Also,
operator, comparisons = ...
is not a valid Elixir match.– Aleksei Matiushkin
Mar 25 at 6:55
Also,
operator, comparisons = ...
is not a valid Elixir match.– Aleksei Matiushkin
Mar 25 at 6:55
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
Show also either the
parse_params
or the content of comparisons
.– Aleksei Matiushkin
Mar 25 at 13:56
Show also either the
parse_params
or the content of comparisons
.– Aleksei Matiushkin
Mar 25 at 13:56
@AlekseiMatiushkin sure, I've added all the relevant code from the module.
parse_params
was a bit of pseudo-code. Thanks again!– FeifanZ
Mar 25 at 14:04
@AlekseiMatiushkin sure, I've added all the relevant code from the module.
parse_params
was a bit of pseudo-code. Thanks again!– FeifanZ
Mar 25 at 14:04
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330217%2fecto-dynamic-fragment-from-runtime-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330217%2fecto-dynamic-fragment-from-runtime-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please post “various compiler complaints” here. We cannot read compiler’s mind.
– Aleksei Matiushkin
Mar 25 at 4:53
Also,
operator, comparisons = ...
is not a valid Elixir match.– Aleksei Matiushkin
Mar 25 at 6:55
@AlekseiMatiushkin syntax fixed; that was just my mistake here simplifying my actual code. Also added details of the compiler errors I'm seeing. Thank you!
– FeifanZ
Mar 25 at 13:13
Show also either the
parse_params
or the content ofcomparisons
.– Aleksei Matiushkin
Mar 25 at 13:56
@AlekseiMatiushkin sure, I've added all the relevant code from the module.
parse_params
was a bit of pseudo-code. Thanks again!– FeifanZ
Mar 25 at 14:04