8000 bugfix: fixed broken client.go generation when last node is a view by marcobeierer · Pull Request #4224 · ent/ent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bugfix: fixed broken client.go generation when last node is a view #4224

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marcobeierer
Copy link
@marcobeierer marcobeierer commented Sep 20, 2024

First of all: thanks for all the work put into this great project.

I ran into a bug with the new «Views» feature. The generation of the client.go breaks if the last node in the nodes list at https://github.com/ent/ent/pull/4224/files#diff-6e7cf13a6cd7f6e95a7743595df8791f1dbe2f99e70c7169022ba35fe2899ba0L483 is a view and not a table. Then the following code gets generated:

// hooks and interceptors per client, for fast access.
type (
	hooks struct {
		Table1, Table2,
	}
	inters struct {
		Table1, Table2, View1 []ent.Interceptor
	}
)

To fix this I added a second list that only contains the tables and introduced another loop to compile the $hooks slice.

The generated code then looks like this:

// hooks and interceptors per client, for fast access.
type (
	hooks struct {
		Table1, Table2 []ent.Hook
	}
	inters struct {
		Table1, Table2, View1 []ent.Interceptor
	}
)

I ran all the integration tests and they passed.

Please let me know if I should change or improve something.

Have a nice day!

@marcobeierer
Copy link
Author

@a8m Do you need anything from me or can I provide something more to getting this fix merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0