-
Notifications
You must be signed in to change notification settings - Fork 874
Expand file tree
/
Copy pathPostgresCompositeType.cs
More file actions
56 lines (48 loc) · 1.6 KB
/
PostgresCompositeType.cs
File metadata and controls
56 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Collections.Generic;
using Npgsql.Internal.Postgres;
namespace Npgsql.PostgresTypes;
/// <summary>
/// Represents a PostgreSQL composite data type, which can hold multiple fields of varying types in a single column.
/// </summary>
/// <remarks>
/// See https://www.postgresql.org/docs/current/static/rowtypes.html.
/// </remarks>
public class PostgresCompositeType : PostgresType
{
/// <summary>
/// Holds the name and types for all fields.
/// </summary>
public IReadOnlyList<Field> Fields => MutableFields;
internal List<Field> MutableFields { get; } = [];
/// <summary>
/// Constructs a representation of a PostgreSQL array data type.
/// </summary>
internal PostgresCompositeType(string ns, string name, uint oid)
: base(ns, name, oid) {}
/// <summary>
/// Constructs a representation of a PostgreSQL domain data type.
/// </summary>
internal PostgresCompositeType(DataTypeName dataTypeName, Oid oid)
: base(dataTypeName, oid) {}
/// <summary>
/// Represents a field in a PostgreSQL composite data type.
/// </summary>
public class Field
{
internal Field(string name, PostgresType type)
{
Name = name;
Type = type;
}
/// <summary>
/// The name of the composite field.
/// </summary>
public string Name { get; }
/// <summary>
/// The type of the composite field.
/// </summary>
public PostgresType Type { get; }
/// <inheritdoc />
public override string ToString() => $"{Name} => {Type}";
}
}