using Npgsql.Internal.Postgres;
namespace Npgsql.PostgresTypes;
///
/// Represents a PostgreSQL array data type, which can hold several multiple values in a single column.
///
///
/// See https://www.postgresql.org/docs/current/static/arrays.html.
///
public class PostgresArrayType : PostgresType
{
///
/// The PostgreSQL data type of the element contained within this array.
///
public PostgresType Element { get; }
///
/// Constructs a representation of a PostgreSQL array data type.
///
protected internal PostgresArrayType(string ns, string name, uint oid, PostgresType elementPostgresType)
: base(ns, name, oid)
{
Element = elementPostgresType;
Element.Array = this;
}
///
/// Constructs a representation of a PostgreSQL array data type.
///
internal PostgresArrayType(DataTypeName dataTypeName, Oid oid, PostgresType elementPostgresType)
: base(dataTypeName, oid)
{
Element = elementPostgresType;
Element.Array = this;
}
// PostgreSQL array types have an underscore-prefixed name (_text), but we
// want to return the public text[] instead
///
internal override string GetPartialNameWithFacets(int typeModifier)
=> Element.GetPartialNameWithFacets(typeModifier) + "[]";
internal override PostgresFacets GetFacets(int typeModifier)
=> Element.GetFacets(typeModifier);
}