all: gofmt -w -r 'interface{} -> any' (#2874)

This commit is contained in:
Ariel Mashraki
2022-08-19 18:23:04 +03:00
committed by GitHub
parent b6c185a660
commit 2c63d1d70e
619 changed files with 3449 additions and 3449 deletions

View File

@@ -18,14 +18,14 @@ import (
// Schema represents an ent.Schema that was loaded from a complied user package.
type Schema struct {
Name string `json:"name,omitempty"`
Config ent.Config `json:"config,omitempty"`
Edges []*Edge `json:"edges,omitempty"`
Fields []*Field `json:"fields,omitempty"`
Indexes []*Index `json:"indexes,omitempty"`
Hooks []*Position `json:"hooks,omitempty"`
Policy []*Position `json:"policy,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
Name string `json:"name,omitempty"`
Config ent.Config `json:"config,omitempty"`
Edges []*Edge `json:"edges,omitempty"`
Fields []*Field `json:"fields,omitempty"`
Indexes []*Index `json:"indexes,omitempty"`
Hooks []*Position `json:"hooks,omitempty"`
Policy []*Position `json:"policy,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
}
// Position describes a position in the schema.
@@ -46,7 +46,7 @@ type Field struct {
Nillable bool `json:"nillable,omitempty"`
Optional bool `json:"optional,omitempty"`
Default bool `json:"default,omitempty"`
DefaultValue interface{} `json:"default_value,omitempty"`
DefaultValue any `json:"default_value,omitempty"`
DefaultKind reflect.Kind `json:"default_kind,omitempty"`
UpdateDefault bool `json:"update_default,omitempty"`
Immutable bool `json:"immutable,omitempty"`
@@ -55,7 +55,7 @@ type Field struct {
Position *Position `json:"position,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
SchemaType map[string]string `json:"schema_type,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
Comment string `json:"comment,omitempty"`
}
@@ -72,17 +72,17 @@ type Edge struct {
Inverse bool `json:"inverse,omitempty"`
Required bool `json:"required,omitempty"`
StorageKey *edge.StorageKey `json:"storage_key,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
Comment string `json:"comment,omitempty"`
}
// Index represents an ent.Index that was loaded from a complied user package.
type Index struct {
Unique bool `json:"unique,omitempty"`
Edges []string `json:"edges,omitempty"`
Fields []string `json:"fields,omitempty"`
StorageKey string `json:"storage_key,omitempty"`
Annotations map[string]interface{} `json:"annotations,omitempty"`
Unique bool `json:"unique,omitempty"`
Edges []string `json:"edges,omitempty"`
Fields []string `json:"fields,omitempty"`
StorageKey string `json:"storage_key,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
}
// NewEdge creates an loaded edge from edge descriptor.
@@ -99,7 +99,7 @@ func NewEdge(ed *edge.Descriptor) *Edge {
Through: ed.Through,
StorageKey: ed.StorageKey,
Comment: ed.Comment,
Annotations: make(map[string]interface{}),
Annotations: make(map[string]any),
}
for _, at := range ed.Annotations {
ne.addAnnotation(at)
@@ -131,7 +131,7 @@ func NewField(fd *field.Descriptor) (*Field, error) {
Validators: len(fd.Validators),
Sensitive: fd.Sensitive,
SchemaType: fd.SchemaType,
Annotations: make(map[string]interface{}),
Annotations: make(map[string]any),
Comment: fd.Comment,
}
for _, at := range fd.Annotations {
@@ -161,7 +161,7 @@ func NewIndex(idx *index.Descriptor) *Index {
Fields: idx.Fields,
Unique: idx.Unique,
StorageKey: idx.StorageKey,
Annotations: make(map[string]interface{}),
Annotations: make(map[string]any),
}
for _, at := range idx.Annotations {
ni.addAnnotation(at)
@@ -175,7 +175,7 @@ func MarshalSchema(schema ent.Interface) (b []byte, err error) {
s := &Schema{
Config: schema.Config(),
Name: indirect(reflect.TypeOf(schema)).Name(),
Annotations: make(map[string]interface{}),
Annotations: make(map[string]any),
}
if err := s.loadMixin(schema); err != nil {
return nil, fmt.Errorf("schema %q: %w", s.Name, err)
@@ -355,7 +355,7 @@ func (f *Field) addAnnotation(an schema.Annotation) {
addAnnotation(f.Annotations, an)
}
func addAnnotation(annotations map[string]interface{}, an schema.Annotation) {
func addAnnotation(annotations map[string]any, an schema.Annotation) {
curr, ok := annotations[an.Name()]
if !ok {
annotations[an.Name()] = an

View File

@@ -159,7 +159,7 @@ func TestMarshalSchema(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "User", schema.Name)
require.Len(t, schema.Annotations, 2)
ant := schema.Annotations["order_config"].(map[string]interface{})
ant := schema.Annotations["order_config"].(map[string]any)
require.Equal(t, ant["FieldName"], "type annotations")
require.Len(t, schema.Fields, 9)
@@ -170,7 +170,7 @@ func TestMarshalSchema(t *testing.T) {
require.Equal(t, field.TypeString, schema.Fields[1].Info.Type)
require.Equal(t, "unknown", schema.Fields[1].DefaultValue)
require.NotEmpty(t, schema.Fields[1].Annotations)
ant = schema.Fields[1].Annotations["order_config"].(map[string]interface{})
ant = schema.Fields[1].Annotations["order_config"].(map[string]any)
require.Equal(t, ant["FieldName"], "name")
require.Equal(t, "nillable", schema.Fields[2].Name)
@@ -213,7 +213,7 @@ func TestMarshalSchema(t *testing.T) {
require.Equal(t, "Group", schema.Edges[0].Type)
require.False(t, schema.Edges[0].Inverse)
require.NotEmpty(t, schema.Edges[0].Annotations)
ant = schema.Edges[0].Annotations["order_config"].(map[string]interface{})
ant = schema.Edges[0].Annotations["order_config"].(map[string]any)
require.Equal(t, ant["FieldName"], "name")
require.Equal(t, "children", schema.Edges[1].Name)
@@ -224,9 +224,9 @@ func TestMarshalSchema(t *testing.T) {
require.True(t, schema.Edges[1].Ref.Unique)
require.Equal(t, "parent_id", schema.Edges[1].Ref.StorageKey.Columns[0])
ant = schema.Edges[2].Annotations["order_config"].(map[string]interface{})
ant = schema.Edges[2].Annotations["order_config"].(map[string]any)
require.Equal(t, ant["FieldName"], "followers")
ant = schema.Edges[2].Ref.Annotations["order_config"].(map[string]interface{})
ant = schema.Edges[2].Ref.Annotations["order_config"].(map[string]any)
require.Equal(t, ant["FieldName"], "following")
require.Equal(t, []string{"name", "address"}, schema.Indexes[0].Fields)
@@ -235,7 +235,7 @@ func TestMarshalSchema(t *testing.T) {
require.Equal(t, []string{"parent"}, schema.Indexes[1].Edges)
require.Equal(t, "user_parent_name", schema.Indexes[1].StorageKey)
require.True(t, schema.Indexes[1].Unique)
ant = schema.Indexes[1].Annotations["partial_index"].(map[string]interface{})
ant = schema.Indexes[1].Annotations["partial_index"].(map[string]any)
require.Equal(t, "age > 20", ant["WhereClause"])
require.Equal(t, "some comment", schema.Fields[0].Comment)