You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Build SQL for MySQL, PostgreSQLor SQLite](#build-sql-for-mysql--postgresql-or-sqlite)
12
+
-[Build SQL for MySQL, PostgreSQL, SQLServer or SQLite](#build-sql-for-mysql--postgresql-sqlserver-or-sqlite)
13
13
-[Using `Struct` as a light weight ORM](#using--struct--as-a-light-weight-orm)
14
14
-[Nested SQL](#nested-sql)
15
15
-[Use `sql.Named` in a builder](#use--sqlnamed--in-a-builder)
@@ -104,9 +104,9 @@ fmt.Println(sql)
104
104
105
105
To learn how to use builders, check out [examples on GoDoc](https://pkg.go.dev/github.com/huandu/go-sqlbuilder#pkg-examples).
106
106
107
-
### Build SQL for MySQL, PostgreSQL or SQLite
107
+
### Build SQL for MySQL, PostgreSQL, SQLServer or SQLite
108
108
109
-
Parameter markers are different in MySQL, PostgreSQL and SQLite. This package provides some methods to set the type of markers (we call it "flavor") in all builders.
109
+
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.
110
110
111
111
By default, all builders uses `DefaultFlavor` to build SQL. The default value is `MySQL`.
112
112
@@ -116,7 +116,7 @@ We can wrap any `Builder` with a default flavor through `WithFlavor`.
116
116
117
117
To be more verbose, we can use `PostgreSQL.NewSelectBuilder()` to create a `SelectBuilder` with the `PostgreSQL` flavor. All builders can be created in this way.
118
118
119
-
Right now, there are only three flavors, `MySQL`, `PostgreSQL` and `SQLite`. Open new issue to me to ask for a new flavor if you find it necessary.
119
+
Right now, there are only three flavors, `MySQL`, `PostgreSQL`, `SQLServer` and `SQLite`. Open new issue to me to ask for a new flavor if you find it necessary.
"SELECT * FROM a WHERE name = ? AND state IN (?, ?, ?, ?, ?)", []interface{}{"I'm fine", 42, int8(8), int16(-16), int32(32), int64(64)},
44
-
"SELECT * FROM a WHERE name = 'I\\'m fine' AND state IN (42, 8, -16, 32, 64)", nil,
45
-
},
46
-
{
47
-
MySQL,
48
-
"SELECT * FROM `a?` WHERE name = \"?\" AND state IN (?, '?', ?, ?, ?, ?, ?)", []interface{}{"\r\n\b\t\x1a\x00\\\"'", uint(42), uint8(8), uint16(16), uint32(32), uint64(64), "useless"},
49
-
"SELECT * FROM `a?` WHERE name = \"?\" AND state IN ('\\r\\n\\b\\t\\Z\\0\\\\\\\"\\'', '?', 42, 8, 16, 32, 64)", nil,
"SELECT * FROM a WHERE name = $3 AND state IN ($2, $4, $1, $6, $5)", []interface{}{"I'm fine", 42, int8(8), int16(-16), int32(32), int64(64)},
75
-
"SELECT * FROM a WHERE name = 8 AND state IN (42, -16, E'I\\'m fine', 64, 32)", nil,
76
-
},
77
-
{
78
-
PostgreSQL,
79
-
"SELECT * FROM $abc$$1$abc$1$1 WHERE name = \"$1\" AND state IN ($2, '$1', $3, $6, $5, $4, $2) $3", []interface{}{"\r\n\b\t\x1a\x00\\\"'", uint(42), uint8(8), uint16(16), uint32(32), uint64(64), "useless"},
80
-
"SELECT * FROM $abc$$1$abc$1E'\\r\\n\\b\\t\\Z\\0\\\\\\\"\\'' WHERE name = \"$1\" AND state IN (42, '$1', 8, 64, 32, 16, 42) 8", nil,
"SELECT * FROM a WHERE name = 'Huan''Du''$1' AND desc = $1", []interface{}{"c'mon"},
95
-
"SELECT * FROM a WHERE name = 'Huan''Du''$1' AND desc = E'c\\'mon'", nil,
96
-
},
97
-
{
98
-
PostgreSQL,
99
-
"SELECT $1", nil,
100
-
"", ErrInterpolateMissingArgs,
101
-
},
102
-
{
103
-
PostgreSQL,
104
-
"SELECT $1", []interface{}{complex(1, 2)},
105
-
"", ErrInterpolateUnsupportedArgs,
106
-
},
107
-
{
108
-
PostgreSQL,
109
-
"SELECT $12345678901234567890", nil,
110
-
"", errOutOfRange,
111
-
},
112
-
113
-
{
114
-
SQLite,
115
-
"SELECT * FROM a WHERE name = ? AND state IN (?, ?, ?, ?, ?)", []interface{}{"I'm fine", 42, int8(8), int16(-16), int32(32), int64(64)},
116
-
"SELECT * FROM a WHERE name = 'I\\'m fine' AND state IN (42, 8, -16, 32, 64)", nil,
117
-
},
118
-
{
119
-
SQLite,
120
-
"SELECT * FROM `a?` WHERE name = \"?\" AND state IN (?, '?', ?, ?, ?, ?, ?)", []interface{}{"\r\n\b\t\x1a\x00\\\"'", uint(42), uint8(8), uint16(16), uint32(32), uint64(64), "useless"},
121
-
"SELECT * FROM `a?` WHERE name = \"?\" AND state IN ('\\r\\n\\b\\t\\Z\\0\\\\\\\"\\'', '?', 42, 8, 16, 32, 64)", nil,
0 commit comments