Localize.Unit.DDL (Localize Units SQL v2.1.0)

Copy Markdown View Source

Functions to return SQL DDL commands that support the creation and deletion of the cldr_unit database type and associated aggregate functions.

Summary

Functions

Returns the SQL string which when executed will define the cldr_unit and cldr_unit_with_usage data types.

Returns the SQL string which when executed will define aggregate functions for the cldr_unit and cldr_unit_with_usage data types.

Returns the SQL string which when executed will drop the aggregate functions for the cldr_unit and cldr_unit_with_usage data types.

Returns the SQL string which when executed will drop the cldr_unit and cldr_unit_with_usage data types.

Returns a string that will Ecto execute a single SQL command.

Returns a string that will Ecto execute each SQL command.

Functions

create_cldr_unit(db_type \\ :postgres)

Returns the SQL string which when executed will define the cldr_unit and cldr_unit_with_usage data types.

Arguments

  • db_type is the type of the database for which the SQL string should be returned. Defaults to :postgres which is currently the only supported database type.

Returns

  • A SQL string that can be executed to create the types.

Examples

iex> is_binary(Localize.Unit.DDL.create_cldr_unit())
true

define_aggregate_functions(db_type \\ :postgres)

Returns the SQL string which when executed will define aggregate functions for the cldr_unit and cldr_unit_with_usage data types.

Arguments

  • db_type is the type of the database for which the SQL string should be returned. Defaults to :postgres which is currently the only supported database type.

Returns

  • A SQL string that can be executed to define the aggregate functions.

Examples

iex> is_binary(Localize.Unit.DDL.define_aggregate_functions())
true

drop_aggregate_functions(db_type \\ :postgres)

Returns the SQL string which when executed will drop the aggregate functions for the cldr_unit and cldr_unit_with_usage data types.

Arguments

  • db_type is the type of the database for which the SQL string should be returned. Defaults to :postgres which is currently the only supported database type.

Returns

  • A SQL string that can be executed to drop the aggregate functions.

Examples

iex> is_binary(Localize.Unit.DDL.drop_aggregate_functions())
true

drop_cldr_unit(db_type \\ :postgres)

Returns the SQL string which when executed will drop the cldr_unit and cldr_unit_with_usage data types.

Arguments

  • db_type is the type of the database for which the SQL string should be returned. Defaults to :postgres which is currently the only supported database type.

Returns

  • A SQL string that can be executed to drop the types.

Examples

iex> is_binary(Localize.Unit.DDL.drop_cldr_unit())
true

execute(sql)

Returns a string that will Ecto execute a single SQL command.

Arguments

  • sql is a single SQL command.

Returns

  • A string of an Ecto execute statement.

Examples

iex> Localize.Unit.DDL.execute("SELECT name FROM customers;")
"execute \"SELECT name FROM customers;\""

execute_each(sql)

Returns a string that will Ecto execute each SQL command.

Arguments

  • sql is a string of SQL commands that are separated by three newlines ("\n"), that is to say two blank lines between commands in the file.

Returns

  • A string of Ecto execute statements.

Examples

iex> Localize.Unit.DDL.execute_each("SELECT name FROM customers;\n\n\nSELECT id FROM orders;")
"execute \"SELECT name FROM customers;\"\nexecute \"SELECT id FROM orders;\""