Skip to content

Commit

Permalink
schema/field: correctly extract package names from type identifier (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Jul 17, 2022
1 parent 01f9733 commit ddc46d3
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 15 deletions.
2 changes: 1 addition & 1 deletion entc/gen/template/import.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
{{- range $f := $fields }}
{{- $pkg := $f.Type.PkgPath }}
{{- if and $pkg (not (hasImport (base $pkg ))) }}
{{- $name := trim (index (split $f.Type.RType.Ident ".") 0) "[]*" }}
{{- $name := $f.Type.PkgName }}
{{ if ne $name (base $pkg) }}{{ $name }} {{ end}}"{{ $pkg }}"
{{- end }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion entc/integration/edgeschema/ent/internal/schema.go

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion entc/integration/ent/entql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions entc/integration/ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 78 additions & 2 deletions entc/integration/ent/mutation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions entc/integration/ent/schema/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ func (Task) Fields() []ent.Field {
Validate(func(i int) error {
return task.Priority(i).Validate()
}),
field.JSON("priorities", map[string]task.Priority{}).
Optional(),
}
}
16 changes: 16 additions & 0 deletions entc/integration/ent/task.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions entc/integration/ent/task/task.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions entc/integration/ent/task/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions entc/integration/ent/task_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ddc46d3

Please sign in to comment.