-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
132 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,27 +11,27 @@ func TestInsert(t *testing.T) { | |
|
||
// By default, an INSERT without values will assume a single entry | ||
expect.SQL( | ||
`INSERT INTO "contacts" ("id", "user_id", "key", "value") VALUES ($1, $2, $3, $4)`, | ||
contacts.Insert(), | ||
`INSERT INTO contacts (id, user_id, key, value) VALUES ($1, $2, $3, $4)`, | ||
nil, nil, nil, nil, | ||
) | ||
|
||
expect.SQL( | ||
`INSERT INTO "users" ("name", "password") VALUES ($1, $2)`, | ||
Insert(users.C("name"), users.C("password")), | ||
`INSERT INTO users (name, password) VALUES ($1, $2)`, | ||
nil, nil, | ||
) | ||
|
||
expect.SQL( | ||
`INSERT INTO "users" ("email", "name") VALUES ($1, $2)`, | ||
users.Insert().Values(user{Name: "admin", Email: "[email protected]"}), | ||
`INSERT INTO users (email, name) VALUES ($1, $2)`, | ||
"[email protected]", "admin", | ||
) | ||
|
||
// Use sql.Values | ||
expect.SQL( | ||
`INSERT INTO "users" ("id", "name") VALUES ($1, $2)`, | ||
users.Insert().Values(Values{"id": 1, "name": "user"}), | ||
`INSERT INTO users (id, name) VALUES ($1, $2)`, | ||
1, "user", | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package mysql | ||
|
||
import ( | ||
_ "github.com/go-sql-driver/mysql" | ||
|
||
"github.com/aodin/sol/dialect" | ||
) | ||
|
||
// MySQL implements the Dialect interface for MySQL databases. | ||
type MySQL struct{} | ||
|
||
// The MySQL dialect must implement the dialect.Dialect interface | ||
var _ dialect.Dialect = &MySQL{} | ||
|
||
// Param returns the MySQL specific parameterization scheme. | ||
func (d *MySQL) Param(i int) string { | ||
return `?` | ||
} | ||
|
||
// Dialect is a constructor for the MySQL Dialect | ||
func Dialect() *MySQL { | ||
return &MySQL{} | ||
} | ||
|
||
// Add the MySQL dialect to the dialect registry | ||
func init() { | ||
dialect.Register("mysql", Dialect()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.