module CQL::Identifier

Overview

Validation for names that end up in SQL as identifiers (aliases, index and constraint names). Values are always bound as parameters, but identifiers cannot be, so anything user-controlled must be restricted to a safe shape.

Defined in:

identifier.cr

Constant Summary

PATTERN = /\A[A-Za-z_][A-Za-z0-9_]*\z/
QUALIFIED_PATTERN = /\A[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?\z/

Class Method Summary

Class Method Detail

def self.valid?(name : String) : Bool #

[View source]
def self.validate!(name : String, kind : String = "identifier") : String #

Returns name unchanged when it is a plain identifier, otherwise raises.


[View source]
def self.validate_qualified!(name : String, kind : String = "identifier") : String #

Like .validate! but also accepts one schema.name qualifier (e.g. DROP INDEX myschema.idx_users_email on PostgreSQL).


[View source]