abstract class Athena::ORM::Platforms::Platform
inherits Reference
#
Describes the SQL dialect and capabilities of a database, such as how identifiers are quoted, how column types are declared, and whether INSERT ... RETURNING is supported.
The platform is determined from the driver connection an AORM::EntityManager is created with, and is available via AORM::Connection#database_platform:
| Driver shard | Platform |
|---|---|
pg |
AORM::Platforms::Postgres |
mysql |
AORM::Platforms::MySQL or AORM::Platforms::Maria, depending on the server's version string |
sqlite3 |
AORM::Platforms::SQLite |
Note
Connections of any other driver aren't supported, and creating an entity manager on one raises NotImplementedError.
Direct known subclasses
Athena::ORM::Platforms::AbstractMySQL
Athena::ORM::Platforms::Postgres
Athena::ORM::Platforms::SQLite
Methods#
#append_lock_hint(from_clause : String, lock_mode : LockMode) : String#
Returns from_clause with the hint that applies lock_mode to the rows it selects.
Todo
Row locking isn't supported yet, so this returns from_clause unchanged.
abstract #big_int_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a big (8 byte) integer column.
#binary_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a fixed or variable-length binary column, e.g. VARBINARY(16).
Raises if a variable-length column has no length.
abstract #blob_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a binary large object column.
abstract #boolean_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a boolean column.
#convert_booleans_to_db_value(value : Bool | Nil) : Bool | Nil#
Converts value into the value bound for a boolean column. Returns it unchanged by default.
Raises if value isn't a Bool, nil, or an Array(Bool).
#convert_booleans_to_db_value(value : Array(Bool)) : Array(Bool)#
Converts value into the value bound for a boolean column. Returns it unchanged by default.
Raises if value isn't a Bool, nil, or an Array(Bool).
#convert_booleans_to_db_value(value : _)#
Converts value into the value bound for a boolean column. Returns it unchanged by default.
Raises if value isn't a Bool, nil, or an Array(Bool).
#convert_from_boolean(value : Nil) : Nil#
Converts value, as read from a boolean column, into a Bool, or nil for a NULL value.
Integers are true unless they're 0.
Raises if value can't be converted.
#convert_from_boolean(value : Bool) : Bool#
Converts value, as read from a boolean column, into a Bool, or nil for a NULL value.
Integers are true unless they're 0.
Raises if value can't be converted.
#convert_from_boolean(value : Int) : Bool#
Converts value, as read from a boolean column, into a Bool, or nil for a NULL value.
Integers are true unless they're 0.
Raises if value can't be converted.
#convert_from_boolean(value : _) : Bool#
Converts value, as read from a boolean column, into a Bool, or nil for a NULL value.
Integers are true unless they're 0.
Raises if value can't be converted.
#date_time_format_string : String#
Returns the Time::Format pattern used to parse date and time values that a driver returns as strings.
abstract #date_time_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a date and time column without a time zone.
#decimal_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as an exact numeric column, e.g. NUMERIC(10, 2).
Raises if column has no precision or scale.
#empty_identity_insert_sql(quoted_table_name : String, quoted_identifier_column_name) : String#
Returns the SQL that inserts a row into quoted_table_name without values for any column, letting the database generate quoted_identifier_column_name.
#float_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a double precision floating point column.
#guid_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a UUID column.
Platforms without a native UUID type declare a 36 character fixed-length string column.
abstract #integer_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as an integer (4 byte) column.
#max_identifier_length : Int32#
Returns the maximum length of any given database identifier, like tables or column names.
#modify_limit_query(sql : String, limit : Int | Nil, offset : Int = 0) : String#
Returns sql with clauses limiting its result to limit rows, skipping the first offset rows.
Raises if offset is negative.
#quote_single_identifier(identifier : String) : String#
Returns identifier quoted for use as a table or column name.
By default, identifiers are wrapped in double quotes, with any embedded double quotes doubled.
#returning_keyword_sql : String#
Returns the keyword that introduces the columns an INSERT returns.
#sequence_next_value_sql(sequence_name : String) : String#
Returns the SQL that fetches the next value of the sequence named sequence_name.
Raises NotImplementedError on platforms without sequences.
#small_float_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a single precision floating point column.
abstract #small_int_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a small (2 byte) integer column.
#string_type_declaration_sql(column : Schema::Column) : String#
Returns the SQL declaring column as a string column, e.g. VARCHAR(255), or CHAR(2) for a fixed-length column.
Raises if a variable-length column has no length, on platforms that require one.
#supports_returning? : Bool#
Returns true if INSERT statements can return values of the inserted row via a RETURNING clause.
Database-generated identifiers are read from that clause when supported, and from the driver's last insert id otherwise. Only the latter is limited to a single identifier column.