Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entc/gen: skip Table() predicate and warn about reserved schema name (Client) #2486

Merged
merged 4 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/md/schema-def.md
Expand Up @@ -58,6 +58,12 @@ the root directory of your project, and can be generated by `entc` as follows:
go run entgo.io/ent/cmd/ent init User Group
```

:::note
Please note, that some schema names (like `Client`) are not available due to
[internal use](https://pkg.go.dev/entgo.io/ent/entc/gen#ValidSchemaName). You can circumvent reserved names by using an
annotation as mentioned [here](schema-annotations.md#custom-table-name).
:::

## It's Just Another ORM

If you are used to the definition of relations over edges, that's fine.
Expand Down
2 changes: 1 addition & 1 deletion entc/gen/template/where.tmpl
Expand Up @@ -41,7 +41,7 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} {
{{/* JSON cannot be compared using "=" and Enum has a type defined with the field name */}}
{{ $hasP := not (or $f.IsJSON $f.IsEnum) }}
{{ $comparable := or $f.ConvertedToBasic $f.Type.Valuer }}
{{ $undeclared := (and (ne $func "Label") (ne $func "Hooks") (ne $func "Policy")) }}
{{ $undeclared := (and (ne $func "Label") (ne $func "Hooks") (ne $func "Policy") (ne $func "Table")) }}
{{- if and $hasP $comparable $undeclared }}
{{ $arg := "v" }}
// {{ $func }} applies equality check predicate on the {{ quote $f.Name }} field. It's identical to {{ $func }}EQ.
Expand Down
12 changes: 12 additions & 0 deletions entc/integration/ent/comment.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/comment/comment.go

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

125 changes: 125 additions & 0 deletions entc/integration/ent/comment/where.go

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

82 changes: 82 additions & 0 deletions entc/integration/ent/comment_create.go

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