Serialize returns the DoltgresType as a byte slice.
()
| 176 | |
| 177 | // Serialize returns the DoltgresType as a byte slice. |
| 178 | func (t *DoltgresType) Serialize() []byte { |
| 179 | writer := utils.NewWriter(256) |
| 180 | writer.VariableUint(0) // Version |
| 181 | // Write the type to the writer |
| 182 | writer.Id(t.ID.AsId()) |
| 183 | writer.Int16(t.TypLength) |
| 184 | writer.Bool(t.PassedByVal) |
| 185 | writer.String(string(t.TypType)) |
| 186 | writer.String(string(t.TypCategory)) |
| 187 | writer.Bool(t.IsPreferred) |
| 188 | writer.Bool(t.IsDefined) |
| 189 | writer.String(t.Delimiter) |
| 190 | writer.Id(t.RelID) |
| 191 | writer.Id(globalFunctionRegistry.GetInternalID(t.SubscriptFunc).AsId()) |
| 192 | writer.Id(t.Elem.ID.AsId()) |
| 193 | writer.Id(t.Array.ID.AsId()) |
| 194 | writer.Id(globalFunctionRegistry.GetInternalID(t.InputFunc).AsId()) |
| 195 | writer.Id(globalFunctionRegistry.GetInternalID(t.OutputFunc).AsId()) |
| 196 | writer.Id(globalFunctionRegistry.GetInternalID(t.ReceiveFunc).AsId()) |
| 197 | writer.Id(globalFunctionRegistry.GetInternalID(t.SendFunc).AsId()) |
| 198 | writer.Id(globalFunctionRegistry.GetInternalID(t.ModInFunc).AsId()) |
| 199 | writer.Id(globalFunctionRegistry.GetInternalID(t.ModOutFunc).AsId()) |
| 200 | writer.Id(globalFunctionRegistry.GetInternalID(t.AnalyzeFunc).AsId()) |
| 201 | writer.String(string(t.Align)) |
| 202 | writer.String(string(t.Storage)) |
| 203 | writer.Bool(t.NotNull) |
| 204 | writer.Id(t.BaseTypeType.ID.AsId()) |
| 205 | writer.Int32(t.TypMod) |
| 206 | writer.Int32(t.NDims) |
| 207 | writer.Id(t.TypCollation.AsId()) |
| 208 | writer.String(t.DefaulBin) |
| 209 | writer.String(t.Default) |
| 210 | writer.VariableUint(uint64(len(t.Acl))) |
| 211 | for _, ac := range t.Acl { |
| 212 | writer.String(ac) |
| 213 | } |
| 214 | writer.VariableUint(uint64(len(t.Checks))) |
| 215 | for _, check := range t.Checks { |
| 216 | writer.String(check.Name) |
| 217 | writer.String(check.CheckExpression) |
| 218 | } |
| 219 | writer.Int32(t.attTypMod) |
| 220 | writer.Id(globalFunctionRegistry.GetInternalID(t.CompareFunc).AsId()) |
| 221 | writer.VariableUint(uint64(len(t.EnumLabels))) |
| 222 | if len(t.EnumLabels) > 0 { |
| 223 | labels := slices.SortedFunc(maps.Values(t.EnumLabels), func(v1 EnumLabel, v2 EnumLabel) int { |
| 224 | return cmp.Compare(v1.ID, v2.ID) |
| 225 | }) |
| 226 | for _, l := range labels { |
| 227 | writer.Id(l.ID.AsId()) |
| 228 | writer.Float32(l.SortOrder) |
| 229 | } |
| 230 | } |
| 231 | writer.VariableUint(uint64(len(t.CompositeAttrs))) |
| 232 | if len(t.CompositeAttrs) > 0 { |
| 233 | for _, l := range t.CompositeAttrs { |
| 234 | writer.Id(l.RelID) |
| 235 | writer.String(l.Name) |
no test coverage detected