Sqlcommenter.Commenter (sqlcommenter v0.2.0-alpha.1)

Documentation for Sqlcommenter.Commenter.

Summary

Functions

Appends serialized data to query

Appends serialized data to query

extracts serialized data from query

The same as to_iodata but it assumes the keys are sorted already.

Encodes enumerable to iodata iex> Sqlcommenter.Commenter.to_iodata(controller: :person, function: :index) [

Encodes enumerable to string iex> Sqlcommenter.Commenter.to_str(controller: :person, function: :index) "controller='person',function='index'"

Functions

Link to this function

append_to_io_query(query, params)

@spec append_to_io_query(iodata(), Keyword.t()) :: iodata()

Appends serialized data to query

iex> query = ["SELECT", [~s{p0."id"}, ", ", ~s{p0."first_name"}], " FROM ", ~s{"person"."person"}, " AS ", "p0"] iex> Sqlcommenter.Commenter.append_to_io_query(query, %{controller: :person, function: :index}) [ ["SELECT", [~s{p0."id"}, ", ", ~s{p0."first_name"}], " FROM ", ~s{"person"."person"}, " AS ", "p0"], " /*", [

["controller", "='", "person", "'"],
",",
["function", "='", "index", "'"]

], "*/"]

Link to this function

append_to_query(query, params)

@spec append_to_query(String.t(), Keyword.t()) :: String.t()

Appends serialized data to query

iex> query = ~s{SELECT p0."id", p0."first_name" FROM "person"."person" AS p0} iex> Sqlcommenter.Commenter.append_to_query(query, %{controller: :person, function: :index}) ~s{SELECT p0."id", p0."first_name" FROM "person"."person" AS p0 } <> "/controller='person',function='index'/"

Link to this function

deserialize(query)

@spec deserialize(String.t()) :: map()

extracts serialized data from query

Example

iex> query = ~s{SELECT p0."id", p0."first_name" FROM "person"."person" AS p0 /request_id='fa2af7b2-d8e1-4e8f-8820-3fd648b73187'/} iex> Sqlcommenter.Commenter.deserialize(query) %{"request_id" => "fa2af7b2-d8e1-4e8f-8820-3fd648b73187"}

Link to this function

sorted_to_iodata(params)

@spec sorted_to_iodata(Keyword.t()) :: iodata()

The same as to_iodata but it assumes the keys are sorted already.

Link to this function

to_iodata(params)

@spec to_iodata(Keyword.t()) :: maybe_improper_list()

Encodes enumerable to iodata iex> Sqlcommenter.Commenter.to_iodata(controller: :person, function: :index) [

["controller", "='", "person", "'"],
",",
["function", "='", "index", "'"]

]

@spec to_str(Keyword.t()) :: String.t()

Encodes enumerable to string iex> Sqlcommenter.Commenter.to_str(controller: :person, function: :index) "controller='person',function='index'"