using Npgsql.Internal.Postgres;
namespace Npgsql.PostgresTypes;
///
/// Represents a PostgreSQL domain type.
///
///
/// See https://www.postgresql.org/docs/current/static/sql-createdomain.html.
///
/// When PostgreSQL returns a RowDescription for a domain type, the type OID is the base type's
/// (so fetching a domain type over text returns a RowDescription for text).
/// However, when a composite type is returned, the type OID there is that of the domain,
/// so we provide "clean" support for domain types.
///
public class PostgresDomainType : PostgresType
{
///
/// The PostgreSQL data type of the base type, i.e. the type this domain is based on.
///
public PostgresType BaseType { get; }
///
/// True if the domain has a NOT NULL constraint, otherwise false.
///
public bool NotNull { get; }
///
/// Constructs a representation of a PostgreSQL domain data type.
///
protected internal PostgresDomainType(string ns, string name, uint oid, PostgresType baseType, bool notNull)
: base(ns, name, oid)
{
BaseType = baseType;
NotNull = notNull;
}
///
/// Constructs a representation of a PostgreSQL domain data type.
///
internal PostgresDomainType(DataTypeName dataTypeName, Oid oid, PostgresType baseType, bool notNull)
: base(dataTypeName, oid)
{
BaseType = baseType;
NotNull = notNull;
}
internal override PostgresFacets GetFacets(int typeModifier)
=> BaseType.GetFacets(typeModifier);
}