Skip to content

Commit

Permalink
Add mysqlx.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Jun 16, 2018
1 parent 6841432 commit 9e01cca
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/docker-compose-mysqlx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: '3'
services:
mysql:
image: mysql/mysql-server:${REFORM_IMAGE_VERSION}
command: --plugin-load=mysqlx=mysqlx.so
environment:
- TZ=Europe/Moscow
- MYSQL_ALLOW_EMPTY_PASSWORD=1
- MYSQL_ROOT_HOST=%
ports:
- 127.0.0.1:3306:3306
- 127.0.0.1:33060:33060
8 changes: 8 additions & 0 deletions .github/test-dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ var configs = []config{
},
"5.7",
},
{
[]string{"mysqlx"},
[]string{
"5.7",
"8.0",
},
"5.7",
},

{
[]string{"sqlite3"},
Expand Down
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ env:
- GORACE="halt_on_error=1"

# Generated with 'go run .github/test-dc.go gen'.
# 21 combinations:
# 23 combinations:
# postgres, pgx: 9.3, 9.4, 9.5, 9.6, 10
# mysql, mysql-traditional: 5.5, 5.6, 5.7, 8.0
# mysqlx: 5.7, 8.0
# sqlite3: dummy
# mssql, sqlserver: latest
matrix:
Expand All @@ -63,6 +64,9 @@ env:
- REFORM_TARGET=mysql-traditional REFORM_IMAGE_VERSION=5.7
- REFORM_TARGET=mysql-traditional REFORM_IMAGE_VERSION=8.0

- REFORM_TARGET=mysqlx REFORM_IMAGE_VERSION=5.7
- REFORM_TARGET=mysqlx REFORM_IMAGE_VERSION=8.0

- REFORM_TARGET=sqlite3 REFORM_IMAGE_VERSION=dummy

- REFORM_TARGET=mssql REFORM_IMAGE_VERSION=latest
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ deps:
go get -u github.com/lib/pq
go get -u github.com/jackc/pgx/stdlib
go get -u github.com/go-sql-driver/mysql
go get -u github.com/AlekSi/mysqlx
go get -u github.com/mattn/go-sqlite3
go get -u github.com/denisenkom/go-mssqldb

Expand Down Expand Up @@ -95,6 +96,15 @@ mysql-traditional: export REFORM_TEST_SOURCE = root@/reform-database?parseTime=t
mysql-traditional: test
make test-db

# run unit tests and integration tests for MySQL (mysqlx driver for X Protocol)
mysqlx: export REFORM_DATABASE = mysql
mysqlx: export REFORM_DRIVER = mysqlx
mysqlx: export REFORM_ROOT_SOURCE = mysqlx://root@127.0.0.1:33060/?_auth-method=PLAIN
mysqlx: export REFORM_INIT_SOURCE = mysqlx://root@127.0.0.1:33060/reform-database?_auth-method=PLAIN&time_zone=UTC&sql_mode=ANSI
mysqlx: export REFORM_TEST_SOURCE = mysqlx://root@127.0.0.1:33060/reform-database?_auth-method=PLAIN&time_zone=UTC&sql_mode=ANSI
mysqlx: test
make test-db

# run unit tests and integration tests for SQLite3
sqlite3: export REFORM_DATABASE = sqlite3
sqlite3: export REFORM_DRIVER = sqlite3
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ as opposed to `interface{}`, type system sidestepping, and runtime reflection. I

Supported SQL dialects:

| RDBMS | Library and drivers | Tested with
| ----- | ------------------- | -----------
| PostgreSQL | [github.com/lib/pq](https://github.com/lib/pq) (`postgres`), [github.com/jackc/pgx/stdlib](https://github.com/jackc/pgx) (`pgx`) | All [supported](https://www.postgresql.org/support/versioning/) versions.
| MySQL | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) (`mysql`) | All [supported](https://www.mysql.com/support/supportedplatforms/database.html) versions.
| SQLite3 | [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) (`sqlite3`) |
| Microsoft SQL Server | [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) (`mssql`, `sqlserver`) | Windows: SQL2008R2SP2, SQL2012SP1, SQL2014, SQL2016. Linux: [`microsoft/mssql-server-linux:latest` Docker image](https://hub.docker.com/r/microsoft/mssql-server-linux/).

Note that for MySQL [`clientFoundRows=true`](https://github.com/go-sql-driver/mysql#clientfoundrows) flag is required.
| RDBMS | Library and drivers | Status
| ----- | ------------------- | -----------
| PostgreSQL | [github.com/lib/pq](https://github.com/lib/pq) (`postgres`) | Stable. Tested with all [supported](https://www.postgresql.org/support/versioning/) versions.
| | [github.com/jackc/pgx/stdlib](https://github.com/jackc/pgx) (`pgx`) | Stable. Tested with all [supported](https://www.postgresql.org/support/versioning/) versions.
| MySQL | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) (`mysql`) | Stable. Tested with all [supported](https://www.mysql.com/support/supportedplatforms/database.html) versions.
| | [github.com/AlekSi/mysqlx](https://github.com/AlekSi/mysqlx) (`mysqlx`) | Experimental. Tested with MySQL 5.7 and 8.0.
| SQLite3 | [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) (`sqlite3`) |
| Microsoft SQL Server | [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) (`mssql`, `sqlserver`) | Stable. Tested on Windows with: SQL2008R2SP2, SQL2012SP1, SQL2014, SQL2016. On Linux with: [`microsoft/mssql-server-linux:latest` Docker image](https://hub.docker.com/r/microsoft/mssql-server-linux/).

Note that for `github.com/go-sql-driver/mysql` [`clientFoundRows=true`](https://github.com/go-sql-driver/mysql#clientfoundrows) flag is required.


## Quickstart
Expand Down
1 change: 1 addition & 0 deletions base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

_ "github.com/AlekSi/mysqlx"
_ "github.com/denisenkom/go-mssqldb"
_ "github.com/go-sql-driver/mysql"
_ "github.com/jackc/pgx/stdlib"
Expand Down
2 changes: 1 addition & 1 deletion dialects/dialects.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func ForDriver(driver string) reform.Dialect {
switch driver {
case "postgres", "pgx":
return postgresql.Dialect
case "mysql":
case "mysql", "mysqlx":
return mysql.Dialect
case "sqlite3":
return sqlite3.Dialect
Expand Down
1 change: 1 addition & 0 deletions reform-db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"time"

_ "github.com/AlekSi/mysqlx"
_ "github.com/denisenkom/go-mssqldb"
_ "github.com/go-sql-driver/mysql"
_ "github.com/jackc/pgx/stdlib"
Expand Down

0 comments on commit 9e01cca

Please sign in to comment.