Skip to content

Commit 1191d33

Browse files
committed
update readme and format code
1 parent 674f3da commit 1191d33

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- [Usage](#usage)
1010
- [Basic usage](#basic-usage)
1111
- [Pre-defined SQL builders](#pre-defined-sql-builders)
12-
- [Build SQL for MySQL, PostgreSQL, SQLServer, SQLite, CQL, or ClickHouse](#build-sql-for-mysql-postgresql-sqlserve-sqlite-or-clickhouse)
12+
- [Build SQL for different systems](#build-sql-for-different-systems)
1313
- [Using `Struct` as a light weight ORM](#using-struct-as-a-light-weight-orm)
1414
- [Nested SQL](#nested-sql)
1515
- [Use `sql.Named` in a builder](#use-sqlnamed-in-a-builder)
@@ -110,9 +110,11 @@ Following are some utility methods to deal with special cases.
110110

111111
To learn how to use builders, check out [examples on GoDoc](https://pkg.go.dev/github.com/huandu/go-sqlbuilder#pkg-examples).
112112

113-
### Build SQL for MySQL, PostgreSQL, SQLServer, SQLite, CQL, or ClickHouse
113+
### Build SQL for different systems
114114

115-
Parameter markers are different in MySQL, PostgreSQL, SQLServer and SQLite. This package provides some methods to set the type of markers (we call it "flavor") in all builders.
115+
SQL syntax and parameter marks vary in different systems. In this package, we introduce a concept called "flavor" to smooth out these difference.
116+
117+
Right now, MySQL, PostgreSQL, SQLServer, SQLite, CQL and ClickHouse are defined in flavor list. Feel free to open issue or send pull request if anyone asks for a new flavor.
116118

117119
By default, all builders uses `DefaultFlavor` to build SQL. The default value is `MySQL`.
118120

args.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ func (args *Args) add(arg interface{}) int {
8686
//
8787
// The format string uses a special syntax to represent arguments.
8888
//
89-
// $? refers successive arguments passed in the call. It works similar as `%v` in `fmt.Sprintf`.
90-
// $0 $1 ... $n refers nth-argument passed in the call. Next $? will use arguments n+1.
91-
// ${name} refers a named argument created by `Named` with `name`.
92-
// $$ is a "$" string.
89+
// $? refers successive arguments passed in the call. It works similar as `%v` in `fmt.Sprintf`.
90+
// $0 $1 ... $n refers nth-argument passed in the call. Next $? will use arguments n+1.
91+
// ${name} refers a named argument created by `Named` with `name`.
92+
// $$ is a "$" string.
9393
func (args *Args) Compile(format string, initialValue ...interface{}) (query string, values []interface{}) {
9494
return args.CompileWithFlavor(format, args.Flavor, initialValue...)
9595
}

select.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ func (sb *SelectBuilder) From(table ...string) *SelectBuilder {
110110
// Join sets expressions of JOIN in SELECT.
111111
//
112112
// It builds a JOIN expression like
113-
// JOIN table ON onExpr[0] AND onExpr[1] ...
113+
//
114+
// JOIN table ON onExpr[0] AND onExpr[1] ...
114115
func (sb *SelectBuilder) Join(table string, onExpr ...string) *SelectBuilder {
115116
sb.marker = selectMarkerAfterJoin
116117
return sb.JoinWithOption("", table, onExpr...)
@@ -119,16 +120,17 @@ func (sb *SelectBuilder) Join(table string, onExpr ...string) *SelectBuilder {
119120
// JoinWithOption sets expressions of JOIN with an option.
120121
//
121122
// It builds a JOIN expression like
122-
// option JOIN table ON onExpr[0] AND onExpr[1] ...
123+
//
124+
// option JOIN table ON onExpr[0] AND onExpr[1] ...
123125
//
124126
// Here is a list of supported options.
125-
// - FullJoin: FULL JOIN
126-
// - FullOuterJoin: FULL OUTER JOIN
127-
// - InnerJoin: INNER JOIN
128-
// - LeftJoin: LEFT JOIN
129-
// - LeftOuterJoin: LEFT OUTER JOIN
130-
// - RightJoin: RIGHT JOIN
131-
// - RightOuterJoin: RIGHT OUTER JOIN
127+
// - FullJoin: FULL JOIN
128+
// - FullOuterJoin: FULL OUTER JOIN
129+
// - InnerJoin: INNER JOIN
130+
// - LeftJoin: LEFT JOIN
131+
// - LeftOuterJoin: LEFT OUTER JOIN
132+
// - RightJoin: RIGHT JOIN
133+
// - RightOuterJoin: RIGHT OUTER JOIN
132134
func (sb *SelectBuilder) JoinWithOption(option JoinOption, table string, onExpr ...string) *SelectBuilder {
133135
sb.joinOptions = append(sb.joinOptions, option)
134136
sb.joinTables = append(sb.joinTables, table)

0 commit comments

Comments
 (0)