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

docs: fix code comment err in Model Join case #2884

Merged
merged 3 commits into from
Sep 4, 2023

Conversation

BugKillerPro
Copy link
Contributor

fix code comment err in Model Join case

@gqcn
Copy link
Member

gqcn commented Aug 21, 2023

@BugKillerPro Thanks for your contribution. There's no comment mistake, but the parameter name might lead misunderstanding. It might be better using another parameter name like tableAliasOrSubuery.

@gqcn gqcn closed this Aug 21, 2023
@gqcn gqcn added the rejected The proposal or PR is not accepted, which might be conflicted with our design or plan. label Aug 21, 2023
@BugKillerPro
Copy link
Contributor Author

BugKillerPro commented Aug 22, 2023

@gqcn

// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
// The parameter `table` can be joined table and its joined condition,
// and also with its alias name.
//
// Eg:
// Model("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
// Model("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
// Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid").
func (m *Model) LeftJoin(table ...string) *Model {
	return m.doJoin("LEFT", table...)
}

Eg:Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid").
got Sql: select * from user u left join (SELECT xxx FROM xxx AS a) on a.uid=u.uid;
and with err : "Every derived table must have its own alias"

if change above Eg to:Model("user", "u").LeftJoin("SELECT xxx FROM xxx","a", "a.uid=u.uid").
we got right Sql: select * from user u left join (SELECT xxx FROM xxx ) AS a on a.uid=u.uid;

@gqcn
Copy link
Member

gqcn commented Aug 23, 2023

@gqcn

// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
// The parameter `table` can be joined table and its joined condition,
// and also with its alias name.
//
// Eg:
// Model("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
// Model("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
// Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid").
func (m *Model) LeftJoin(table ...string) *Model {
	return m.doJoin("LEFT", table...)
}

Eg:Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid"). got Sql: select * from user u left join (SELECT xxx FROM xxx AS a) on a.uid=u.uid; and with err : "Every derived table must have its own alias"

if change above Eg to:Model("user", "u").LeftJoin("SELECT xxx FROM xxx","a", "a.uid=u.uid"). we got right Sql: select * from user u left join (SELECT xxx FROM xxx ) AS a on a.uid=u.uid;

Awesome! Would you please update the parameter name as well?

@gqcn gqcn reopened this Aug 23, 2023
@gqcn gqcn removed the rejected The proposal or PR is not accepted, which might be conflicted with our design or plan. label Aug 23, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (74bf1b4) 79.15% compared to head (ebae618) 79.14%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2884      +/-   ##
==========================================
- Coverage   79.15%   79.14%   -0.01%     
==========================================
  Files         638      638              
  Lines       52570    52570              
==========================================
- Hits        41611    41609       -2     
- Misses       8892     8894       +2     
  Partials     2067     2067              
Flag Coverage Δ
go-1.18-386 79.23% <100.00%> (+0.04%) ⬆️
go-1.18-amd64 79.22% <100.00%> (+0.01%) ⬆️
go-1.19-386 79.11% <100.00%> (+0.01%) ⬆️
go-1.19-amd64 79.10% <100.00%> (+<0.01%) ⬆️
go-1.20-386 79.19% <100.00%> (-0.04%) ⬇️
go-1.20-amd64 79.23% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
database/gdb/gdb_model_join.go 92.53% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BugKillerPro
Copy link
Contributor Author

@gqcn

// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
// The parameter `table` can be joined table and its joined condition,
// and also with its alias name.
//
// Eg:
// Model("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
// Model("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
// Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid").
func (m *Model) LeftJoin(table ...string) *Model {
	return m.doJoin("LEFT", table...)
}

Eg:Model("user", "u").LeftJoin("SELECT xxx FROM xxx AS a", "a.uid=u.uid"). got Sql: select * from user u left join (SELECT xxx FROM xxx AS a) on a.uid=u.uid; and with err : "Every derived table must have its own alias"
if change above Eg to:Model("user", "u").LeftJoin("SELECT xxx FROM xxx","a", "a.uid=u.uid"). we got right Sql: select * from user u left join (SELECT xxx FROM xxx ) AS a on a.uid=u.uid;

Awesome! Would you please update the parameter name as well?
@gqcn
Done!

database/gdb/gdb_model_join.go Outdated Show resolved Hide resolved
database/gdb/gdb_model_join.go Outdated Show resolved Hide resolved
@BugKillerPro BugKillerPro reopened this Aug 29, 2023
@gqcn gqcn merged commit e60262f into gogf:master Sep 4, 2023
9 checks passed
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.

4 participants