Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
给自定义SQL增加了根据条件判断是否生成的功能。因为有时候在查询时,某些字段需要根据前端传过来的查询参数来决定是否需要,例如对文章标题或者内容字段进行查找时,只有当前端传递过来的title这个字段不为空时才需要添加。使用类似下列情况
像下面这个生成的sql为
在使用自定义SQL时,直接把
Get()
的返回值当作参数传给db.Where()
会出现下列问题,所有的参数都只会被放到第一个变量里面而已。所以应该接受
Get()
的返回值后,再分别传入