diff --git a/.github/docker-compose-mysqlx.yml b/.github/docker-compose-mysqlx.yml new file mode 100644 index 00000000..47d304a7 --- /dev/null +++ b/.github/docker-compose-mysqlx.yml @@ -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 diff --git a/.github/test-dc.go b/.github/test-dc.go index 92d1c4f8..0e49e45b 100644 --- a/.github/test-dc.go +++ b/.github/test-dc.go @@ -43,6 +43,14 @@ var configs = []config{ }, "5.7", }, + { + []string{"mysqlx"}, + []string{ + "5.7", + "8.0", + }, + "5.7", + }, { []string{"sqlite3"}, diff --git a/.travis.yml b/.travis.yml index 1d530018..b55d4f0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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 diff --git a/Makefile b/Makefile index 138f06c5..081246df 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/README.md b/README.md index a2fa5ec0..a22cab9f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/base_test.go b/base_test.go index fcb7399d..259efd62 100644 --- a/base_test.go +++ b/base_test.go @@ -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" diff --git a/dialects/dialects.go b/dialects/dialects.go index 906838d6..a2d984ea 100644 --- a/dialects/dialects.go +++ b/dialects/dialects.go @@ -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 diff --git a/reform-db/main.go b/reform-db/main.go index dc5db645..b6e3569a 100644 --- a/reform-db/main.go +++ b/reform-db/main.go @@ -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"