using System.Diagnostics; using JetBrains.Annotations; 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. /// [PublicAPI] public PostgresType Element { get; } /// /// Constructs a representation of a PostgreSQL array data type. /// protected internal PostgresArrayType(string ns, string internalName, uint oid, PostgresType elementPostgresType) : base(ns, elementPostgresType.Name + "[]", internalName, oid) { Debug.Assert(internalName == '_' + elementPostgresType.InternalName); 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); } }