<%
def make_query_value(it)
  if it[:alter].present?
    return ".clone()"
  end
  case it[:type]
  when "enum" then
    ".iter().join(\",\")"
  when "string" then
    ""
  when "date" then
    ".format(\"%Y-%m-%dT%H:%M:%SZ\").to_string()"
  else
    ".to_string()"
  end
end

def make_form(it)
  if it[:constant].present?
    "(\"#{it[:name]}\", \"#{it[:constant]}\".to_owned()),"
  else
    "(\"#{it[:name]}\", self.#{(it[:alter].present? ? it[:alter] : it[:name]).make_name.make_field}#{make_query_value(it)}),"
  end
end

%><% if form.present? %>
let form_parameters = vec![<% form.each do |it| %>
    <%= make_form(it) %><% end %>
];
<% end %><% if required_queries.present? && !non_required_queries.present? %>let query_parameters = vec![<% required_queries.each do |it| %>
    ("<%= it[:name] %>", self.<%= it[:name].make_name.make_field %><%= make_query_value(it) %>),<% end %>
];<% elsif queries.present? %>let mut query_parameters = vec![];<% required_queries.each do |it| %>
query_parameters.push(("<%= it[:name] %>", self.<%= it[:name].make_name.make_field %><%= make_query_value(it) %>));<% end %><% non_required_queries.each do |it| %>
if let Some(<%= it[:name].make_name.make_field %>) = self.<%= it[:name].make_name.make_field %> {
    query_parameters.push(("<%= it[:name] %>", <%= it[:name].make_name.make_field %><%= make_query_value(it) %>));
}<% end %><% end %>