mysqldialect

package
v0.0.0-...-e338c6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeMySQLDialectOptions

func SafeMySQLDialectOptions() *goqu.SQLDialectOptions

func SafeMySQLDialectOptionsV8

func SafeMySQLDialectOptionsV8() *goqu.SQLDialectOptions
Example
type userRow struct {
	Id   string `db:"id"`
	Name string `db:"name"`
}
dialect := goqu.Dialect("safemysql8")

var query string
query, _, _ = dialect.Insert("users").Rows(userRow{Id: "1", Name: "John"}).ToSQL()
fmt.Println("normal update: " + query)

query, _, _ = dialect.Insert("users").Rows(userRow{Id: "1", Name: "John"}).As("new").
	OnConflict(goqu.DoUpdate("", goqu.Record{"name": goqu.T("new").Col("name")})).ToSQL()
fmt.Println("upsert: " + query)
Output:

normal update: INSERT INTO `users` (`id`, `name`) VALUES ('1', 'John')
upsert: INSERT INTO `users` (`id`, `name`) VALUES ('1', 'John') AS `new` ON DUPLICATE KEY UPDATE `name`=`new`.`name`

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL