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

Add singlestore mysql dialect variation #395

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
src
*.iml
coverage.*
coverage.*
.env
7 changes: 7 additions & 0 deletions dialect/mysql/mysql.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package mysql

import (
"github.com/doug-martin/goqu/v9"

Check failure on line 4 in dialect/mysql/mysql.go

View workflow job for this annotation

GitHub Actions / lint

"github.com/doug-martin/goqu/v9" imported but not used (typecheck)
"github.com/doug-martin/goqu/v9/exp"
)

func DialectOptions() *goqu.SQLDialectOptions {

Check failure on line 8 in dialect/mysql/mysql.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `goqu` (typecheck)
opts := goqu.DefaultDialectOptions()

opts.SupportsReturn = false
Expand Down Expand Up @@ -75,13 +75,20 @@
return opts
}

func DialectOptionsV8() *goqu.SQLDialectOptions {

Check failure on line 78 in dialect/mysql/mysql.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `goqu` (typecheck)
opts := DialectOptions()
opts.SupportsWindowFunction = true
return opts
}

func DialectOptionsVSinglestore() *goqu.SQLDialectOptions {

Check failure on line 84 in dialect/mysql/mysql.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `goqu` (typecheck)
opts := DialectOptionsV8()
opts.SupportsWithCTE = true
return opts
}

func init() {
goqu.RegisterDialect("mysql", DialectOptions())
goqu.RegisterDialect("mysql8", DialectOptionsV8())
goqu.RegisterDialect("mysqlSinglestore", DialectOptionsVSinglestore())
}
5 changes: 5 additions & 0 deletions dialect/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ func (mt *mysqlTest) TestToSQL() {
ds: ds.Prepared(true).Where(goqu.L("? = ?", goqu.C("int"), 10)),
sql: "SELECT * FROM `entry` WHERE `int` = ?", args: []interface{}{int64(10)},
},
sqlTestCase{
ds: ds.With("entrySubselect", goqu.From("entry").Select("id").Where(goqu.C("int").Gt(8))).
Select(goqu.Star()).Where(goqu.Ex{ "id": goqu.Op{ "in": goqu.From("entrySubselect").Select(goqu.Star()) } }),
sql: "WITH `entrySubselect` as (SELECT id from `entry` where int > 5) select * from `entry`",
},
)
}

Expand Down
Loading