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

FindOneByUsernameDeletedAt method generated by goctl model failed to find records with 'deleted_at' field is Null. #4529

Closed
dahuzihaidao opened this issue Dec 27, 2024 · 2 comments

Comments

@dahuzihaidao
Copy link

Describe the bug
A clear and concise description of what the bug is.

Below is the FindOneByUsernameDeletedAt method, and when I use this method to query specific username with deleted_at equaling Null, no rows are returned.

l.svcCtx.UsersModel.FindOneByUsernameDeletedAt(l.ctx, req.Username, sql.NullTime{Valid: false})

image

**Possible solutions"
image

Need to use "deleted_at is Null“ to filter data. What is the best workaround for now? I believe that the columns with Null value all have this similar problem.

@kesonan
Copy link
Collaborator

kesonan commented Dec 28, 2024

I don't think this is a code generation problem. When generating code, I can't determine whether your sql.NullTime is null.

@dahuzihaidao
Copy link
Author

dahuzihaidao commented Dec 28, 2024

I don't think this is a code generation problem. When generating code, I can't determine whether your sql.NullTime is null.

Got it. So to work this around, I can only set a default value like '1970-01-01 00:00:00' to indicate/mock NULL value instead?

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

No branches or pull requests

2 participants