Structure
PostgresLTree
A Swift representation of the Postgres
ltree type, which comes from the ltree extension.struct PostgresLTree
Overview
An ltree is a path of labels separated by dots, e.g. Top.Science.Astronomy. The extension needs to be enabled in the database before the type can be used:
CREATE EXTENSION IF NOT EXISTS ltree;
Since the type comes from an extension it doesn’t have a fixed OID, so each connection looks it up the first time it’s used. If the extension is dropped and created again, connections that already used the type keep the old OID and need to be reconnected.
To skip the lookup, bind the path as a String and cast it in SQL instead:
try await client.query("SELECT \(path.description)::ltree")
Values are always sent as text, and can be decoded from text or from binary, which Postgres supports for ltree since version 13.
For more information see https://www.postgresql.org/docs/current/ltree.html.
Topics
Initializers
init(labels: [String])Create anltreefrom its labels, from the root to the leaf.
Instance Properties
var labels: [String]The labels of the path, from the root to the leaf.
Default Implementations
Relationships
Conforms To
PostgresDecodablePostgresDynamicTypeEncodablePostgresThrowingDynamicTypeEncodableSwift.CopyableSwift.CustomStringConvertibleSwift.EquatableSwift.EscapableSwift.ExpressibleByArrayLiteralSwift.HashableSwift.LosslessStringConvertibleSwift.SendableSwift.SendableMetatype