Selecto.Builder.Sql.Helpers (Selecto v0.4.5)

Copy Markdown

Helper functions shared by SQL builder modules.

Responsibilities include:

  • adapter-aware identifier quoting
  • identifier safety validation
  • selector and join string construction
  • support helpers for parameterized join aliases

Summary

Functions

Build join alias string for parameterized joins.

Build selector string for parameterized joins with signature support.

Always quote an identifier through the active adapter.

Get the appropriate quote character for identifiers based on the database adapter. PostgreSQL uses double quotes, MySQL uses backticks, SQLite uses double quotes.

Maybe quote an identifier - only adds quotes if necessary.

Check if an identifier needs quoting. Only quote if it's a reserved word, contains special characters, or has mixed case.

Wrap an identifier with the appropriate quotes for the database adapter. This is the adapter-aware version of double_wrap.

Functions

build_join_string(selecto, join)

build_parameterized_join_string(selecto, join, parameter_signature \\ nil)

Build join alias string for parameterized joins.

build_parameterized_selector_string(selecto, join, field, parameter_signature \\ nil)

Build selector string for parameterized joins with signature support.

build_selector_string(selecto, join, field)

check_string(str)

double_wrap(str)

force_quote_identifier(selecto, str)

Always quote an identifier through the active adapter.

get_quote_char(selecto)

Get the appropriate quote character for identifiers based on the database adapter. PostgreSQL uses double quotes, MySQL uses backticks, SQLite uses double quotes.

maybe_quote_identifier(str)

Maybe quote an identifier - only adds quotes if necessary.

needs_quoting?(str)

Check if an identifier needs quoting. Only quote if it's a reserved word, contains special characters, or has mixed case.

quote_identifier(selecto, str)

Wrap an identifier with the appropriate quotes for the database adapter. This is the adapter-aware version of double_wrap.

single_wrap(val)