struct Athena::ORM::Types::Guid
inherits Athena::ORM::Types::Type
#
Holds UUID values, stored in a UUID column on Postgres, and as their 36 character string form elsewhere.
UUID properties are mapped to this type by default.
Note
AORM::EntityManager#find takes a UUID identifier as its string form.
Methods#
#sql_declaration(column : Schema::Column, platform : AORM::Platforms::Platform) : ::String#
Returns the SQL used to declare column as this type on platform, e.g. VARCHAR(255).
Built-in types delegate to the matching declaration method of AORM::Platforms::Platform, which custom types can reuse.
Todo
Nothing in the ORM generates schema yet, so this isn't called by the ORM itself.
#to_crystal_value(value : DB::ResultSet, platform : Platforms::Platform) : UUID | Nil#
Reads the next column from value and converts it into the Crystal value this type represents.
Returns nil for a NULL value.
Used while hydrating entities. Advances the cursor by exactly one column.
#to_crystal_value(value : _, platform : Platforms::Platform) : UUID | Nil#
Converts value, as read from the database, into the Crystal value this type represents.
Returns nil for a NULL value, and raises if value can't be converted.
Used for values that have already been read, such as a database-generated identifier.
Each type defines this once, as the place for its translation logic (parsing, narrowing, decoding, etc.).
It accepts any input, since drivers disagree on the Crystal type of some columns, and validates it inside the body, e.g. with case value.
#to_db(value : _, platform : AORM::Platforms::Platform)#
Converts value, a property's Crystal value, into the value bound to the query. Returns value unchanged by default.
The returned value must be one the database driver can bind (DB::Any), otherwise executing the query raises.
Converts a UUID into its string form, since drivers can't bind UUID but every database accepts its string form.