不要怂,就是干,撸起袖子干!

Commit b7f5b84e by Jan Aagaard Meier

chore(ci): Update build matrix (#5918)

* chore(ci): Update build matrix

* 🔥 Mariadb

* Remove 0.12 from build matrix

* Update .travis.yml
1 parent 75c3cb87
...@@ -13,3 +13,4 @@ coverage-* ...@@ -13,3 +13,4 @@ coverage-*
site site
docs/api/tmp.md docs/api/tmp.md
ssce.js ssce.js
coverage
language: node_js language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs-v1"
- "iojs-v2"
sudo: false sudo: false
node_js:
- "4"
cache: cache:
directories: directories:
- node_modules - node_modules
env: env:
- DIALECT=mysql global:
- DIALECT=postgres - CC=clang
- DIALECT=postgres-native - CXX=clang++
- DIALECT=sqlite - npm_config_clang=1
- DIALECT=mariadb - COVERALLS_REPO_TOKEN=751SiA6QhY5EH4P2ygq7JFWulqiD2ETXO
- DIALECT=mssql - COVERALLS_PARALLEL=true
matrix:
- DIALECT=mysql
- DIALECT=postgres
- DIALECT=postgres-native
- DIALECT=sqlite
- DIALECT=mssql
addons:
apt:
sources:
- llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
packages:
- clang-3.6
- g++-4.8
addons: addons:
postgresql: "9.4" postgresql: "9.4"
...@@ -32,10 +44,17 @@ script: ...@@ -32,10 +44,17 @@ script:
- "npm test" - "npm test"
matrix: matrix:
fast_finish: true
include: include:
- node_js: "0.10" - node_js: "6"
env: COVERAGE=true env: COVERAGE=true DIALECT=mysql
allow_failures: - node_js: "6"
- node_js: "0.10" env: COVERAGE=true DIALECT=postgres
env: COVERAGE=true - node_js: "6"
env: COVERAGE=true DIALECT=postgres-native
- node_js: "6"
env: COVERAGE=true DIALECT=sqlite
- node_js: "6"
env: COVERAGE=true DIALECT=mssql
notifications:
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN
...@@ -131,7 +131,7 @@ All tests are located in the `test` folder (which contains the ...@@ -131,7 +131,7 @@ All tests are located in the `test` folder (which contains the
lovely [Mocha](http://visionmedia.github.io/mocha/) tests). lovely [Mocha](http://visionmedia.github.io/mocha/) tests).
```console ```console
$ npm run test-all || test-mysql || test-sqlite || test-mssql || test-postgres || test-mariadb || test-postgres-native $ npm run test-all || test-mysql || test-sqlite || test-mssql || test-postgres || test-postgres-native
$ # alternatively you can pass database credentials with $variables when testing $ # alternatively you can pass database credentials with $variables when testing
$ DIALECT=dialect SEQ_DB=database SEQ_USER=user SEQ_PW=password npm test $ DIALECT=dialect SEQ_DB=database SEQ_USER=user SEQ_PW=password npm test
......
FROM node:5 FROM node:6
RUN apt-get install libpq-dev RUN apt-get install libpq-dev
COPY package.json / COPY package.json /
ENV NPM_CONFIG_LOGLEVEL error
RUN npm install RUN npm install
WORKDIR /sequelize WORKDIR /sequelize
......
# Sequelize # Sequelize
[![Build Status](https://travis-ci.org/sequelize/sequelize.svg?branch=master)](https://travis-ci.org/sequelize/sequelize) [![Dependency Status](https://david-dm.org/sequelize/sequelize.svg)](https://david-dm.org/sequelize/sequelize) [![Test Coverage](https://codeclimate.com/github/sequelize/sequelize/badges/coverage.svg)](https://codeclimate.com/github/sequelize/sequelize) [![Build Status](https://travis-ci.org/sequelize/sequelize.svg?branch=master)](https://travis-ci.org/sequelize/sequelize)
[![Coverage Status](https://coveralls.io/repos/github/sequelize/sequelize/badge.svg?branch=master)](https://coveralls.io/github/sequelize/sequelize?branch=master)
[![Bountysource](https://www.bountysource.com/badge/team?team_id=955&style=bounties_received)](https://www.bountysource.com/teams/sequelize/issues?utm_source=Sequelize&utm_medium=shield&utm_campaign=bounties_received) [![Bountysource](https://www.bountysource.com/badge/team?team_id=955&style=bounties_received)](https://www.bountysource.com/teams/sequelize/issues?utm_source=Sequelize&utm_medium=shield&utm_campaign=bounties_received)
[![Slack Status](http://sequelize-slack.herokuapp.com/badge.svg)](http://sequelize-slack.herokuapp.com) [![Slack Status](http://sequelize-slack.herokuapp.com/badge.svg)](http://sequelize-slack.herokuapp.com)
Sequelize is a promise-based Node.js/io.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, read replication and more. Sequelize is a promise-based Node.js/io.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server. It features solid transaction support, relations, read replication and more.
[Documentation](http://sequelize.readthedocs.org/en/latest/) [Documentation](http://sequelize.readthedocs.org/en/latest/)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
- [REMOVED] Support for `pool:false` - [REMOVED] Support for `pool:false`
- [REMOVED] Default transaction isolation level [#5094](https://github.com/sequelize/sequelize/issues/5094) - [REMOVED] Default transaction isolation level [#5094](https://github.com/sequelize/sequelize/issues/5094)
- [ADDED] Add logging for mysql warnings, observant of the `showWarnings` option. [#5900](https://github.com/sequelize/sequelize/issues/5900) - [ADDED] Add logging for mysql warnings, observant of the `showWarnings` option. [#5900](https://github.com/sequelize/sequelize/issues/5900)
- [REMOVED] MariaDB dialect
## BC breaks: ## BC breaks:
- `hookValidate` removed in favor of `validate` with `hooks: true | false`. `validate` returns a promise which is rejected if validation fails - `hookValidate` removed in favor of `validate` with `hooks: true | false`. `validate` returns a promise which is rejected if validation fails
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
- (MySQL) `BIGINT` now gets converted to string when number is too big - (MySQL) `BIGINT` now gets converted to string when number is too big
- Removed support for `pool:false`, if you still want to use single connection set `pool.max` to `1` - Removed support for `pool:false`, if you still want to use single connection set `pool.max` to `1`
- Removed default `REPEATABLE_READ` transaction isolation, use config option to explicitly set it - Removed default `REPEATABLE_READ` transaction isolation, use config option to explicitly set it
- Removed MariaDB dialect - this was just a thin wrapper around MySQL, so using `dialect: 'mysql'` instead should work with no further changes
# 3.23.2 # 3.23.2
- [FIXED] Type validation now works with non-strings due to updated validator@5.0.0 [#5861](https://github.com/sequelize/sequelize/pull/5861) - [FIXED] Type validation now works with non-strings due to updated validator@5.0.0 [#5861](https://github.com/sequelize/sequelize/pull/5861)
......
...@@ -671,7 +671,7 @@ To obtain Instances for the newly created values, you will need to query for the ...@@ -671,7 +671,7 @@ To obtain Instances for the newly created values, you will need to query for the
| [options.hooks=true] | Boolean | Run before / after bulk create hooks? | | [options.hooks=true] | Boolean | Run before / after bulk create hooks? |
| [options.individualHooks=false] | Boolean | Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true. | | [options.individualHooks=false] | Boolean | Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true. |
| [options.ignoreDuplicates=false] | Boolean | Ignore duplicate values for primary keys? (not supported by postgres) | | [options.ignoreDuplicates=false] | Boolean | Ignore duplicate values for primary keys? (not supported by postgres) |
| [options.updateOnDuplicate] | Array | Fields to update if row key already exists (on duplicate key update)? (only supported by mysql & mariadb). By default, all fields are updated. | | [options.updateOnDuplicate] | Array | Fields to update if row key already exists (on duplicate key update)? (only supported by mysql). By default, all fields are updated. |
| [options.transaction] | Transaction | Transaction to run query under | | [options.transaction] | Transaction | Transaction to run query under |
| [options.logging=false] | Function | A function that gets executed while running the query to log the sql. | | [options.logging=false] | Function | A function that gets executed while running the query to log the sql. |
| [options.returning=false] | Boolean | Append RETURNING * to get back auto generated values (Postgres only) | | [options.returning=false] | Boolean | Append RETURNING * to get back auto generated values (Postgres only) |
...@@ -775,7 +775,7 @@ of affected rows, while the second element is the actual affected rows (only sup ...@@ -775,7 +775,7 @@ of affected rows, while the second element is the actual affected rows (only sup
| [options.sideEffects=true] | Boolean | Whether or not to update the side effects of any virtual setters. | | [options.sideEffects=true] | Boolean | Whether or not to update the side effects of any virtual setters. |
| [options.individualHooks=false] | Boolean | Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks | | [options.individualHooks=false] | Boolean | Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks |
| [options.returning=false] | Boolean | Return the affected rows (only for postgres) | | [options.returning=false] | Boolean | Return the affected rows (only for postgres) |
| [options.limit] | Number | How many rows to update (only for mysql and mariadb) | | [options.limit] | Number | How many rows to update (only for mysql) |
| [options.logging=false] | Function | A function that gets executed while running the query to log the sql. | | [options.logging=false] | Function | A function that gets executed while running the query to log the sql. |
| [options.benchmark=false] | Boolean | Print query execution time in milliseconds when logging SQL. | | [options.benchmark=false] | Boolean | Print query execution time in milliseconds when logging SQL. |
| [options.transaction] | Transaction | Transaction to run query under | | [options.transaction] | Transaction | Transaction to run query under |
...@@ -792,4 +792,4 @@ Run a describe query on the table. The result will be return to the listener as ...@@ -792,4 +792,4 @@ Run a describe query on the table. The result will be return to the listener as
*** ***
_This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_ _This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_
\ No newline at end of file
...@@ -45,7 +45,7 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {}) ...@@ -45,7 +45,7 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
| [username=null] | String | The username which is used to authenticate against the database. | | [username=null] | String | The username which is used to authenticate against the database. |
| [password=null] | String | The password which is used to authenticate against the database. | | [password=null] | String | The password which is used to authenticate against the database. |
| [options={}] | Object | An object with options. | | [options={}] | Object | An object with options. |
| [options.dialect='mysql'] | String | The dialect of the database you are connecting to. One of mysql, postgres, sqlite, mariadb and mssql. | | [options.dialect='mysql'] | String | The dialect of the database you are connecting to. One of mysql, postgres, sqlite and mssql. |
| [options.dialectModulePath=null] | String | If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'pg.js' here | | [options.dialectModulePath=null] | String | If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'pg.js' here |
| [options.dialectOptions] | Object | An object of additional options, which are passed directly to the connection library | | [options.dialectOptions] | Object | An object of additional options, which are passed directly to the connection library |
| [options.storage] | String | Only used by sqlite. Defaults to ':memory:' | | [options.storage] | String | Only used by sqlite. Defaults to ':memory:' |
......
...@@ -35,7 +35,6 @@ $ npm install --save sequelize ...@@ -35,7 +35,6 @@ $ npm install --save sequelize
$ npm install --save pg # for postgres $ npm install --save pg # for postgres
$ npm install --save mysql # for mysql $ npm install --save mysql # for mysql
$ npm install --save sqlite3 # for sqlite $ npm install --save sqlite3 # for sqlite
$ npm install --save mariasql # for mariasql
``` ```
## Connecting to the database ## Connecting to the database
...@@ -45,7 +44,7 @@ Open the created directory in your favorite text editor and add a new file calle ...@@ -45,7 +44,7 @@ Open the created directory in your favorite text editor and add a new file calle
```js ```js
var Sequelize = require('sequelize') var Sequelize = require('sequelize')
, sequelize = new Sequelize('database_name', 'username', 'password', { , sequelize = new Sequelize('database_name', 'username', 'password', {
dialect: "mysql", // or 'sqlite', 'postgres', 'mariadb', 'mssql' dialect: "mysql", // or 'sqlite', 'postgres', 'mssql'
port: 3306 // or 5432 (for postgres) port: 3306 // or 5432 (for postgres)
}); });
......
...@@ -7,7 +7,7 @@ $ npm install --save sequelize ...@@ -7,7 +7,7 @@ $ npm install --save sequelize
# And one of the following: # And one of the following:
$ npm install --save pg pg-hstore $ npm install --save pg pg-hstore
$ npm install --save mysql // For both mysql and mariadb dialects $ npm install --save mysql
$ npm install --save sqlite3 $ npm install --save sqlite3
$ npm install --save tedious // MSSQL $ npm install --save tedious // MSSQL
``` ```
...@@ -19,7 +19,7 @@ Sequelize will setup a connection pool on initialization so you should ideally o ...@@ -19,7 +19,7 @@ Sequelize will setup a connection pool on initialization so you should ideally o
```js ```js
var sequelize = new Sequelize('database', 'username', 'password', { var sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost', host: 'localhost',
dialect: 'mysql'|'mariadb'|'sqlite'|'postgres'|'mssql', dialect: 'mysql'|'sqlite'|'postgres'|'mssql',
pool: { pool: {
max: 5, max: 5,
......
...@@ -53,12 +53,12 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -53,12 +53,12 @@ var sequelize = new Sequelize('database', 'username', 'password', {
   
// the sql dialect of the database // the sql dialect of the database
// - default is 'mysql' // - default is 'mysql'
// - currently supported: 'mysql', 'sqlite', 'postgres', 'mariadb', 'mssql' // - currently supported: 'mysql', 'sqlite', 'postgres', 'mssql'
dialect: 'mysql', dialect: 'mysql',
   
// you can also pass any dialect options to the underlying dialect library // you can also pass any dialect options to the underlying dialect library
// - default is empty // - default is empty
// - currently supported: 'mysql', 'mariadb', 'postgres', 'mssql' // - currently supported: 'mysql', 'postgres', 'mssql'
dialectOptions: { dialectOptions: {
socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock', socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock',
supportBigNumbers: true, supportBigNumbers: true,
...@@ -181,18 +181,7 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -181,18 +181,7 @@ var sequelize = new Sequelize('database', 'username', 'password', {
**Note:** You can pass options directly to dialect library by setting the **Note:** You can pass options directly to dialect library by setting the
`dialectOptions` parameter. See [Options][0] `dialectOptions` parameter. See [Options][0]
for examples (currently only mysql and mariadb are supported). for examples (currently only mysql is supported).
### MariaDB
For MariaDB compatibility you have to install the package `mariasql@~0.1.20`.
The configuration needs to look like this:
```js
var sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'mariadb'
})
```
### SQLite ### SQLite
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
<span>Sequelize</span> <span>Sequelize</span>
</div> </div>
Sequelize is a promise-based ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, Sequelize is a promise-based ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL and features solid transaction support, relations, read replication and
MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and
more. more.
[Installation](docs/getting-started/) [Installation](docs/getting-started/)
......
...@@ -986,7 +986,6 @@ _.each(dataTypes, function (dataType) { ...@@ -986,7 +986,6 @@ _.each(dataTypes, function (dataType) {
dataTypes.postgres = require('./dialects/postgres/data-types')(dataTypes); dataTypes.postgres = require('./dialects/postgres/data-types')(dataTypes);
dataTypes.mysql = require('./dialects/mysql/data-types')(dataTypes); dataTypes.mysql = require('./dialects/mysql/data-types')(dataTypes);
dataTypes.mariadb = dataTypes.mysql;
dataTypes.sqlite = require('./dialects/sqlite/data-types')(dataTypes); dataTypes.sqlite = require('./dialects/sqlite/data-types')(dataTypes);
dataTypes.mssql = require('./dialects/mssql/data-types')(dataTypes); dataTypes.mssql = require('./dialects/mssql/data-types')(dataTypes);
......
...@@ -38,12 +38,7 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -38,12 +38,7 @@ ConnectionManager = function(dialect, sequelize) {
ConnectionManager.prototype.refreshTypeParser = function(dataTypes) { ConnectionManager.prototype.refreshTypeParser = function(dataTypes) {
_.each(dataTypes, function (dataType, key) { _.each(dataTypes, function (dataType, key) {
if (dataType.hasOwnProperty('parse')) { if (dataType.hasOwnProperty('parse')) {
var dialectName = this.dialectName; if (dataType.types[this.dialectName]) {
if (dialectName === 'mariadb') {
dialectName = 'mysql';
}
if (dataType.types[dialectName]) {
this.$refreshTypeParser(dataType); this.$refreshTypeParser(dataType);
} else { } else {
throw new Error('Parse function not supported for type ' + dataType.key + ' in dialect ' + this.dialectName); throw new Error('Parse function not supported for type ' + dataType.key + ' in dialect ' + this.dialectName);
......
'use strict';
var MySQLDialect = require('../mysql')
, util = require('util');
var MariaDialect = function(sequelize) {
MySQLDialect.call(this, sequelize);
};
util.inherits(MariaDialect, MySQLDialect);
MariaDialect.prototype.name = 'mariadb';
module.exports = MariaDialect;
...@@ -2109,7 +2109,7 @@ Model.prototype.insertOrUpdate = Model.prototype.upsert; ...@@ -2109,7 +2109,7 @@ Model.prototype.insertOrUpdate = Model.prototype.upsert;
* @param {Boolean} [options.hooks=true] Run before / after bulk create hooks? * @param {Boolean} [options.hooks=true] Run before / after bulk create hooks?
* @param {Boolean} [options.individualHooks=false] Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true. * @param {Boolean} [options.individualHooks=false] Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true.
* @param {Boolean} [options.ignoreDuplicates=false] Ignore duplicate values for primary keys? (not supported by postgres) * @param {Boolean} [options.ignoreDuplicates=false] Ignore duplicate values for primary keys? (not supported by postgres)
* @param {Array} [options.updateOnDuplicate] Fields to update if row key already exists (on duplicate key update)? (only supported by mysql & mariadb). By default, all fields are updated. * @param {Array} [options.updateOnDuplicate] Fields to update if row key already exists (on duplicate key update)? (only supported by mysql). By default, all fields are updated.
* @param {Transaction} [options.transaction] Transaction to run query under * @param {Transaction} [options.transaction] Transaction to run query under
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging). * @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
...@@ -2136,7 +2136,7 @@ Model.prototype.bulkCreate = function(records, options) { ...@@ -2136,7 +2136,7 @@ Model.prototype.bulkCreate = function(records, options) {
if (options.ignoreDuplicates && ['postgres', 'mssql'].indexOf(dialect) !== -1) { if (options.ignoreDuplicates && ['postgres', 'mssql'].indexOf(dialect) !== -1) {
return Promise.reject(new Error(dialect + ' does not support the \'ignoreDuplicates\' option.')); return Promise.reject(new Error(dialect + ' does not support the \'ignoreDuplicates\' option.'));
} }
if (options.updateOnDuplicate && ['mysql', 'mariadb'].indexOf(dialect) === -1) { if (options.updateOnDuplicate && dialect !== 'mysql') {
return Promise.reject(new Error(dialect + ' does not support the \'updateOnDuplicate\' option.')); return Promise.reject(new Error(dialect + ' does not support the \'updateOnDuplicate\' option.'));
} }
...@@ -2445,7 +2445,7 @@ Model.prototype.restore = function(options) { ...@@ -2445,7 +2445,7 @@ Model.prototype.restore = function(options) {
* @param {Boolean} [options.sideEffects=true] Whether or not to update the side effects of any virtual setters. * @param {Boolean} [options.sideEffects=true] Whether or not to update the side effects of any virtual setters.
* @param {Boolean} [options.individualHooks=false] Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks * @param {Boolean} [options.individualHooks=false] Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks
* @param {Boolean} [options.returning=false] Return the affected rows (only for postgres) * @param {Boolean} [options.returning=false] Return the affected rows (only for postgres)
* @param {Number} [options.limit] How many rows to update (only for mysql and mariadb) * @param {Number} [options.limit] How many rows to update (only for mysql)
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging). * @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
* @param {Transaction} [options.transaction] Transaction to run query under * @param {Transaction} [options.transaction] Transaction to run query under
......
...@@ -364,8 +364,7 @@ QueryInterface.prototype.removeColumn = function(tableName, attributeName, optio ...@@ -364,8 +364,7 @@ QueryInterface.prototype.removeColumn = function(tableName, attributeName, optio
// mssql needs special treatment as it cannot drop a column with a default or foreign key constraint // mssql needs special treatment as it cannot drop a column with a default or foreign key constraint
return MSSSQLQueryInterface.removeColumn.call(this, tableName, attributeName, options); return MSSSQLQueryInterface.removeColumn.call(this, tableName, attributeName, options);
case 'mysql': case 'mysql':
case 'mariadb': // mysql needs special treatment as it cannot drop a column with a foreign key constraint
// mysql/maria needs special treatment as it cannot drop a column with a foreign key constraint
return MySQLQueryInterface.removeColumn.call(this, tableName, attributeName, options); return MySQLQueryInterface.removeColumn.call(this, tableName, attributeName, options);
default: default:
var sql = this.QueryGenerator.removeColumnQuery(tableName, attributeName); var sql = this.QueryGenerator.removeColumnQuery(tableName, attributeName);
......
...@@ -64,7 +64,7 @@ var url = require('url') ...@@ -64,7 +64,7 @@ var url = require('url')
* @param {String} [options.username=null] The username which is used to authenticate against the database. * @param {String} [options.username=null] The username which is used to authenticate against the database.
* @param {String} [options.password=null] The password which is used to authenticate against the database. * @param {String} [options.password=null] The password which is used to authenticate against the database.
* @param {String} [options.database=null] The name of the database * @param {String} [options.database=null] The name of the database
* @param {String} [options.dialect='mysql'] The dialect of the database you are connecting to. One of mysql, postgres, sqlite, mariadb and mssql. * @param {String} [options.dialect='mysql'] The dialect of the database you are connecting to. One of mysql, postgres, sqlite and mssql.
* @param {String} [options.dialectModulePath=null] If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'pg.js' here * @param {String} [options.dialectModulePath=null] If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'pg.js' here
* @param {Object} [options.dialectOptions] An object of additional options, which are passed directly to the connection library * @param {Object} [options.dialectOptions] An object of additional options, which are passed directly to the connection library
* @param {String} [options.storage] Only used by sqlite. Defaults to ':memory:' * @param {String} [options.storage] Only used by sqlite. Defaults to ':memory:'
...@@ -216,9 +216,6 @@ var Sequelize = function(database, username, password, options) { ...@@ -216,9 +216,6 @@ var Sequelize = function(database, username, password, options) {
// Requiring the dialect in a switch-case to keep the // Requiring the dialect in a switch-case to keep the
// require calls static. (Browserify fix) // require calls static. (Browserify fix)
switch (this.getDialect()){ switch (this.getDialect()){
case 'mariadb':
Dialect = require('./dialects/mariadb');
break;
case 'mssql': case 'mssql':
Dialect = require('./dialects/mssql'); Dialect = require('./dialects/mssql');
break; break;
...@@ -232,7 +229,7 @@ var Sequelize = function(database, username, password, options) { ...@@ -232,7 +229,7 @@ var Sequelize = function(database, username, password, options) {
Dialect = require('./dialects/sqlite'); Dialect = require('./dialects/sqlite');
break; break;
default: default:
throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mariadb, mssql, mysql, postgres, and sqlite.'); throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
} }
this.dialect = new Dialect(this); this.dialect = new Dialect(this);
...@@ -873,7 +870,7 @@ Sequelize.prototype.set = function( variables, options ) { ...@@ -873,7 +870,7 @@ Sequelize.prototype.set = function( variables, options ) {
// Prepare options // Prepare options
options = Utils._.extend({}, this.options.set, typeof options === 'object' && options || {}); options = Utils._.extend({}, this.options.set, typeof options === 'object' && options || {});
if (['mysql', 'mariadb'].indexOf(this.options.dialect) === -1) { if (this.options.dialect !== 'mysql') {
throw new Error('sequelize.set is only supported for mysql'); throw new Error('sequelize.set is only supported for mysql');
} }
if (!options.transaction || !(options.transaction instanceof Transaction) ) { if (!options.transaction || !(options.transaction instanceof Transaction) ) {
......
site_name: Sequelize | The Node.js / io.js ORM for PostgreSQL, MySQL, SQLite and MSSQL site_name: Sequelize | The Node.js / io.js ORM for PostgreSQL, MySQL, SQLite and MSSQL
site_description: Sequelize is an ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, MariaDB, SQLite and MSSQL. site_description: Sequelize is an ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL.
repo_url: https://github.com/sequelize/sequelize repo_url: https://github.com/sequelize/sequelize
site_favicon: favicon.ico site_favicon: favicon.ico
site_url: http://docs.sequelizejs.com site_url: http://docs.sequelizejs.com
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
"chai-spies": "^0.7.0", "chai-spies": "^0.7.0",
"commander": "^2.6.0", "commander": "^2.6.0",
"continuation-local-storage": "^3.1.4", "continuation-local-storage": "^3.1.4",
"coveralls": "^2.11.9",
"dox": "~0.8.0", "dox": "~0.8.0",
"git": "^0.1.5", "git": "^0.1.5",
"hints": "^0.2.0", "hints": "^0.2.0",
...@@ -88,7 +89,7 @@ ...@@ -88,7 +89,7 @@
], ],
"main": "index", "main": "index",
"scripts": { "scripts": {
"test": "if [ $COVERAGE ]; then npm run codeclimate; else npm run jshint && npm run teaser && npm run test-unit && npm run test-integration; fi", "test": "if [ $COVERAGE ]; then npm run coveralls; else npm run jshint && npm run teaser && npm run test-unit && npm run test-integration; fi",
"test-docker": "docker-compose run sequelize /bin/sh -c \"npm run test-all\"", "test-docker": "docker-compose run sequelize /bin/sh -c \"npm run test-all\"",
"test-docker-unit": "docker-compose run sequelize /bin/sh -c \"npm run test-unit-all\"", "test-docker-unit": "docker-compose run sequelize /bin/sh -c \"npm run test-unit-all\"",
"test-docker-integration": "docker-compose run sequelize /bin/sh -c \"npm run test-integration-all\"", "test-docker-integration": "docker-compose run sequelize /bin/sh -c \"npm run test-integration-all\"",
...@@ -100,38 +101,29 @@ ...@@ -100,38 +101,29 @@
"test-unit-mysql": "DIALECT=mysql npm run test-unit", "test-unit-mysql": "DIALECT=mysql npm run test-unit",
"test-unit-postgres": "DIALECT=postgres npm run test-unit", "test-unit-postgres": "DIALECT=postgres npm run test-unit",
"test-unit-postgres-native": "DIALECT=postgres-native npm run test-unit", "test-unit-postgres-native": "DIALECT=postgres-native npm run test-unit",
"test-unit-mariadb": "DIALECT=mariadb npm run test-unit",
"test-unit-sqlite": "DIALECT=sqlite npm run test-unit", "test-unit-sqlite": "DIALECT=sqlite npm run test-unit",
"test-unit-mssql": "DIALECT=mssql npm run test-unit", "test-unit-mssql": "DIALECT=mssql npm run test-unit",
"test-unit-all": "npm run test-unit-mysql && npm run test-unit-postgres && npm run test-unit-postgres-native && npm run test-unit-mssql && npm run test-unit-sqlite && npm run test-unit-mariadb", "test-unit-all": "npm run test-unit-mysql && npm run test-unit-postgres && npm run test-unit-postgres-native && npm run test-unit-mssql && npm run test-unit-sqlite",
"test-integration": "./node_modules/.bin/mocha --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter spec --grep \"$GREP\" 'test/integration/**/*.test.js'", "test-integration": "./node_modules/.bin/mocha --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter spec --grep \"$GREP\" 'test/integration/**/*.test.js'",
"test-integration-mysql": "DIALECT=mysql npm run test-integration", "test-integration-mysql": "DIALECT=mysql npm run test-integration",
"test-integration-postgres": "DIALECT=postgres npm run test-integration", "test-integration-postgres": "DIALECT=postgres npm run test-integration",
"test-integration-postgres-native": "DIALECT=postgres-native npm run test-integration", "test-integration-postgres-native": "DIALECT=postgres-native npm run test-integration",
"test-integration-mariadb": "DIALECT=mariadb npm run test-integration",
"test-integration-sqlite": "DIALECT=sqlite npm run test-integration", "test-integration-sqlite": "DIALECT=sqlite npm run test-integration",
"test-integration-mssql": "DIALECT=mssql npm run test-integration", "test-integration-mssql": "DIALECT=mssql npm run test-integration",
"test-integration-all": "npm run test-integration-mysql && npm run test-integration-postgres && npm run test-integration-postgres-native && npm run test-integration-mssql && npm run test-integration-sqlite && npm run test-integration-mariadb", "test-integration-all": "npm run test-integration-mysql && npm run test-integration-postgres && npm run test-integration-postgres-native && npm run test-integration-mssql && npm run test-integration-sqlite",
"test-mysql": "DIALECT=mysql npm test", "test-mysql": "DIALECT=mysql npm test",
"test-sqlite": "DIALECT=sqlite npm test", "test-sqlite": "DIALECT=sqlite npm test",
"test-postgres": "DIALECT=postgres npm test", "test-postgres": "DIALECT=postgres npm test",
"test-pgsql": "npm run test-postgres", "test-pgsql": "npm run test-postgres",
"test-postgres-native": "DIALECT=postgres-native npm test", "test-postgres-native": "DIALECT=postgres-native npm test",
"test-postgresn": "npm run test-postgres-native", "test-postgresn": "npm run test-postgres-native",
"test-mariadb": "DIALECT=mariadb npm test",
"test-mssql": "DIALECT=mssql npm test", "test-mssql": "DIALECT=mssql npm test",
"test-all": "npm run test-mysql && npm run test-sqlite && npm run test-postgres && npm run test-postgres-native && npm run test-mariadb && npm run test-mssql", "test-all": "npm run test-mysql && npm run test-sqlite && npm run test-postgres && npm run test-postgres-native && npm run test-mssql",
"cover": "rm -rf coverage && npm run teaser && COVERAGE=true ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -t 30000 --ui tdd 'test/integration/**/*.test.js'", "cover": "rm -rf coverage && npm run teaser && npm run cover-integration && npm run cover-unit && npm run merge-coverage",
"cover-mysql": "DIALECT=mysql npm run cover && mv coverage coverage-mysql", "cover-integration": "COVERAGE=true ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -t 30000 --ui tdd 'test/integration/**/*.test.js' && mv coverage/lcov.info coverage/integration.info",
"cover-sqlite": "DIALECT=sqlite npm run cover && mv coverage coverage-sqlite", "cover-unit": "COVERAGE=true ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -t 30000 --ui tdd 'test/unit/**/*.test.js'&& mv coverage/lcov.info coverage/unit.info",
"cover-postgres": "DIALECT=postgres npm run cover && mv coverage coverage-postgres", "merge-coverage": "./node_modules/.bin/lcov-result-merger 'coverage/*.info' 'coverage/lcov.info'",
"cover-postgres-native": "DIALECT=postgres-native npm run cover && mv coverage coverage-postgres-native", "coveralls": "npm run cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"cover-mariadb": "DIALECT=mariadb npm run cover && mv coverage coverage-mariadb",
"cover-mssql": "DIALECT=mssql npm run cover && mv coverage coverage-mssql",
"cover-all": "npm run cover-mysql && npm run cover-postgres && npm run cover-postgres-native && npm run cover-mssql && npm run cover-sqlite && npm run cover-mariadb && npm run merge-coverage",
"merge-coverage": "rm -rf coverage && mkdir coverage && ./node_modules/.bin/lcov-result-merger 'coverage-*/lcov.info' 'coverage/lcov.info'",
"codeclimate-send": "npm install -g codeclimate-test-reporter && CODECLIMATE_REPO_TOKEN=ce835a510bbf423a5ab5400a9bdcc2ec2d189d840b31657c6ee7cb9916b161d6 codeclimate-test-reporter < coverage/lcov.info",
"codeclimate": "npm run cover-all && npm run codeclimate-send",
"sscce": "docker-compose run sequelize /bin/sh -c \"node sscce.js\"", "sscce": "docker-compose run sequelize /bin/sh -c \"node sscce.js\"",
"sscce-mysql": "DIALECT=mysql npm run sscce", "sscce-mysql": "DIALECT=mysql npm run sscce",
"sscce-postgres": "DIALECT=postgres npm run sscce", "sscce-postgres": "DIALECT=postgres npm run sscce",
......
...@@ -56,17 +56,5 @@ module.exports = { ...@@ -56,17 +56,5 @@ module.exports = {
max: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 idle: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
} }
},
mariadb: {
database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root',
password: process.env.SEQ_MYSQL_PW || process.env.SEQ_PW || null,
host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: {
max: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
}
} }
}; };
...@@ -16,12 +16,6 @@ var chai = require('chai') ...@@ -16,12 +16,6 @@ var chai = require('chai')
describe(Support.getTestDialectTeaser('Configuration'), function() { describe(Support.getTestDialectTeaser('Configuration'), function() {
describe('Connections problems should fail with a nice message', function() { describe('Connections problems should fail with a nice message', function() {
it('when we don\'t have the correct server details', function() { it('when we don\'t have the correct server details', function() {
if (dialect === 'mariadb') {
console.log('This dialect doesn\'t support me :(');
expect(true).to.be.true; // Silence Buster
return;
}
var seq = new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {storage: '/path/to/no/where/land', logging: false, host: '0.0.0.1', port: config[dialect].port, dialect: dialect}); var seq = new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {storage: '/path/to/no/where/land', logging: false, host: '0.0.0.1', port: config[dialect].port, dialect: dialect});
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
// SQLite doesn't have a breakdown of error codes, so we are unable to discern between the different types of errors. // SQLite doesn't have a breakdown of error codes, so we are unable to discern between the different types of errors.
...@@ -32,12 +26,6 @@ describe(Support.getTestDialectTeaser('Configuration'), function() { ...@@ -32,12 +26,6 @@ describe(Support.getTestDialectTeaser('Configuration'), function() {
}); });
it('when we don\'t have the correct login information', function() { it('when we don\'t have the correct login information', function() {
if (dialect === 'mariadb') {
console.log('This dialect doesn\'t support me :(');
expect(true).to.be.true; // Silence Buster
return;
}
if (dialect === 'mssql') { if (dialect === 'mssql') {
// NOTE: Travis seems to be having trouble with this test against the // NOTE: Travis seems to be having trouble with this test against the
// AWS instance. Works perfectly fine on a local setup. // AWS instance. Works perfectly fine on a local setup.
...@@ -57,7 +45,7 @@ describe(Support.getTestDialectTeaser('Configuration'), function() { ...@@ -57,7 +45,7 @@ describe(Support.getTestDialectTeaser('Configuration'), function() {
it('when we don\'t have a valid dialect.', function() { it('when we don\'t have a valid dialect.', function() {
expect(function() { expect(function() {
new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {host: '0.0.0.1', port: config[dialect].port, dialect: 'some-fancy-dialect'}); new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, {host: '0.0.0.1', port: config[dialect].port, dialect: 'some-fancy-dialect'});
}).to.throw(Error, 'The dialect some-fancy-dialect is not supported. Supported dialects: mariadb, mssql, mysql, postgres, and sqlite.'); }).to.throw(Error, 'The dialect some-fancy-dialect is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
}); });
}); });
......
...@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() { ...@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
it('calls parse and stringify for GEOMETRY', function () { it('calls parse and stringify for GEOMETRY', function () {
var Type = new Sequelize.GEOMETRY(); var Type = new Sequelize.GEOMETRY();
if (['postgres', 'mysql', 'mariadb'].indexOf(dialect) !== -1) { if (['postgres', 'mysql'].indexOf(dialect) !== -1) {
return testSuccess(Type, { type: "Point", coordinates: [125.6, 10.1] }); return testSuccess(Type, { type: "Point", coordinates: [125.6, 10.1] });
} else { } else {
// Not implemented yet // Not implemented yet
...@@ -292,7 +292,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() { ...@@ -292,7 +292,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
//This case throw unhandled exception //This case throw unhandled exception
return User.findAll(); return User.findAll();
}).then(function(users){ }).then(function(users){
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
// MySQL will return NULL, becuase they lack EMPTY geometry data support. // MySQL will return NULL, becuase they lack EMPTY geometry data support.
expect(users[0].field).to.be.eql(null); expect(users[0].field).to.be.eql(null);
} else if (dialect === 'postgres' || dialect === 'postgres-native') { } else if (dialect === 'postgres' || dialect === 'postgres-native') {
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
var chai = require('chai') var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../../support') , Support = require(__dirname + '/../../support')
, dialect = Support.getTestDialect()
, DataTypes = require(__dirname + '/../../../../lib/data-types'); , DataTypes = require(__dirname + '/../../../../lib/data-types');
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
describe('[MYSQL Specific] Associations', function() { describe('[MYSQL Specific] Associations', function() {
describe('many-to-many', function() { describe('many-to-many', function() {
describe('where tables have the same prefix', function() { describe('where tables have the same prefix', function() {
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
var chai = require('chai') var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../../support') , Support = require(__dirname + '/../../support')
, dialect = Support.getTestDialect()
, sinon = require('sinon') , sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../../lib/data-types'); , DataTypes = require(__dirname + '/../../../../lib/data-types');
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
describe('[MYSQL Specific] Connector Manager', function() { describe('[MYSQL Specific] Connector Manager', function() {
it('works correctly after being idle', function() { it('works correctly after being idle', function() {
var User = this.sequelize.define('User', { username: DataTypes.STRING }) var User = this.sequelize.define('User', { username: DataTypes.STRING })
...@@ -55,7 +56,7 @@ if (Support.dialectIsMySQL()) { ...@@ -55,7 +56,7 @@ if (Support.dialectIsMySQL()) {
}); });
// This should run only on direct mysql // This should run only on direct mysql
if (Support.dialectIsMySQL(true)) { if (dialect === 'mysql') {
it('should maintain connection', function() { it('should maintain connection', function() {
var sequelize = Support.createSequelizeInstance({pool: {min: 1, max: 1, handleDisconnects: true, idle: 5000}}) var sequelize = Support.createSequelizeInstance({pool: {min: 1, max: 1, handleDisconnects: true, idle: 5000}})
, cm = sequelize.connectionManager , cm = sequelize.connectionManager
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
var chai = require('chai') var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../../support') , Support = require(__dirname + '/../../support')
, dialect = Support.getTestDialect()
, DataTypes = require(__dirname + '/../../../../lib/data-types') , DataTypes = require(__dirname + '/../../../../lib/data-types')
, config = require(__dirname + '/../../../config/config'); , config = require(__dirname + '/../../../config/config');
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
describe('[MYSQL Specific] DAOFactory', function() { describe('[MYSQL Specific] DAOFactory', function() {
describe('constructor', function() { describe('constructor', function() {
it('handles extended attributes (unique)', function() { it('handles extended attributes (unique)', function() {
......
...@@ -1140,7 +1140,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -1140,7 +1140,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
} }
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
it('supports limit clause', function() { it('supports limit clause', function() {
var self = this var self = this
, data = [{ username: 'Peter', secretValue: '42' }, , data = [{ username: 'Peter', secretValue: '42' },
...@@ -2135,7 +2135,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2135,7 +2135,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
}); });
if (Support.dialectIsMySQL() || dialect === 'sqlite') { if (dialect === 'mysql' || dialect === 'sqlite') {
it('should take schemaDelimiter into account if applicable', function() { it('should take schemaDelimiter into account if applicable', function() {
var test = 0; var test = 0;
var UserSpecialUnderscore = this.sequelize.define('UserSpecialUnderscore', {age: Sequelize.INTEGER}, {schema: 'hello', schemaDelimiter: '_'}); var UserSpecialUnderscore = this.sequelize.define('UserSpecialUnderscore', {age: Sequelize.INTEGER}, {schema: 'hello', schemaDelimiter: '_'});
...@@ -2175,7 +2175,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2175,7 +2175,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return UserPublic.schema('special').sync({ force: true }).then(function() { return UserPublic.schema('special').sync({ force: true }).then(function() {
return self.sequelize.queryInterface.describeTable('Publics', { return self.sequelize.queryInterface.describeTable('Publics', {
logging: function(sql) { logging: function(sql) {
if (dialect === 'sqlite' || Support.dialectIsMySQL() || dialect === 'mssql') { if (dialect === 'sqlite' || dialect === 'mysql' || dialect === 'mssql') {
expect(sql).to.not.contain('special'); expect(sql).to.not.contain('special');
count++; count++;
} }
...@@ -2188,7 +2188,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2188,7 +2188,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return self.sequelize.queryInterface.describeTable('Publics', { return self.sequelize.queryInterface.describeTable('Publics', {
schema: 'special', schema: 'special',
logging: function(sql) { logging: function(sql) {
if (dialect === 'sqlite' || Support.dialectIsMySQL() || dialect === 'mssql') { if (dialect === 'sqlite' || dialect === 'mysql' || dialect === 'mssql') {
expect(sql).to.contain('special'); expect(sql).to.contain('special');
count++; count++;
} }
...@@ -2331,7 +2331,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2331,7 +2331,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return Post.sync({logging: _.once(function(sql) { return Post.sync({logging: _.once(function(sql) {
if (dialect === 'postgres') { if (dialect === 'postgres') {
expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/); expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/);
} else if (Support.dialectIsMySQL()) { } else if (dialect === 'mysql') {
expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/); expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/);
} else if (dialect === 'mssql') { } else if (dialect === 'mssql') {
expect(sql).to.match(/FOREIGN KEY \(\[authorId\]\) REFERENCES \[authors\] \(\[id\]\)/); expect(sql).to.match(/FOREIGN KEY \(\[authorId\]\) REFERENCES \[authors\] \(\[id\]\)/);
...@@ -2356,7 +2356,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2356,7 +2356,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return Post.sync({logging: _.once(function(sql) { return Post.sync({logging: _.once(function(sql) {
if (dialect === 'postgres') { if (dialect === 'postgres') {
expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/); expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/);
} else if (Support.dialectIsMySQL()) { } else if (dialect === 'mysql') {
expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/); expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/);
} else if (dialect === 'sqlite') { } else if (dialect === 'sqlite') {
expect(sql).to.match(/`authorId` INTEGER REFERENCES `authors` \(`id`\)/); expect(sql).to.match(/`authorId` INTEGER REFERENCES `authors` \(`id`\)/);
...@@ -2388,10 +2388,8 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2388,10 +2388,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return; return;
}).catch (function(err) { }).catch (function(err) {
if (Support.dialectIsMySQL(true)) { if (dialect === 'mysql') {
expect(err.message).to.match(/ER_CANNOT_ADD_FOREIGN|ER_CANT_CREATE_TABLE/); expect(err.message).to.match(/ER_CANNOT_ADD_FOREIGN|ER_CANT_CREATE_TABLE/);
} else if (dialect === 'mariadb') {
expect(err.message).to.match(/Can\'t create table/);
} else if (dialect === 'sqlite') { } else if (dialect === 'sqlite') {
// the parser should not end up here ... see above // the parser should not end up here ... see above
expect(1).to.equal(2); expect(1).to.equal(2);
......
...@@ -705,7 +705,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -705,7 +705,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('is possible to use casting when creating an instance', function() { it('is possible to use casting when creating an instance', function() {
var self = this var self = this
, type = Support.dialectIsMySQL() ? 'signed' : 'integer' , type = dialect === 'mysql' ? 'signed' : 'integer'
, match = false; , match = false;
return this.User.create({ return this.User.create({
...@@ -728,7 +728,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -728,7 +728,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
, type = this.sequelize.cast(this.sequelize.cast(this.sequelize.literal('1-2'), 'integer'), 'integer') , type = this.sequelize.cast(this.sequelize.cast(this.sequelize.literal('1-2'), 'integer'), 'integer')
, match = false; , match = false;
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
type = this.sequelize.cast(this.sequelize.cast(this.sequelize.literal('1-2'), 'unsigned'), 'signed'); type = this.sequelize.cast(this.sequelize.cast(this.sequelize.literal('1-2'), 'unsigned'), 'signed');
} }
...@@ -736,7 +736,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -736,7 +736,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
intVal: type intVal: type
}, { }, {
logging: function(sql) { logging: function(sql) {
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
expect(sql).to.contain('CAST(CAST(1-2 AS UNSIGNED) AS SIGNED)'); expect(sql).to.contain('CAST(CAST(1-2 AS UNSIGNED) AS SIGNED)');
} else { } else {
expect(sql).to.contain('CAST(CAST(1-2 AS INTEGER) AS INTEGER)'); expect(sql).to.contain('CAST(CAST(1-2 AS INTEGER) AS INTEGER)');
...@@ -755,7 +755,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -755,7 +755,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
var self = this; var self = this;
return this.User.create({ return this.User.create({
intVal: this.sequelize.literal('CAST(1-2 AS ' + (Support.dialectIsMySQL() ? 'SIGNED' : 'INTEGER') + ')') intVal: this.sequelize.literal('CAST(1-2 AS ' + (dialect === 'mysql' ? 'SIGNED' : 'INTEGER') + ')')
}).then(function(user) { }).then(function(user) {
return self.User.findById(user.id).then(function(user) { return self.User.findById(user.id).then(function(user) {
expect(user.intVal).to.equal(-1); expect(user.intVal).to.equal(-1);
...@@ -918,7 +918,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -918,7 +918,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return UserNull.create({ username: 'foo2', smth: null }).catch(function(err) { return UserNull.create({ username: 'foo2', smth: null }).catch(function(err) {
expect(err).to.exist; expect(err).to.exist;
expect(err.get('smth')[0].path).to.equal('smth'); expect(err.get('smth')[0].path).to.equal('smth');
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
// We need to allow two different errors for MySQL, see: // We need to allow two different errors for MySQL, see:
// http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables // http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables
expect(err.get('smth')[0].type).to.match(/notNull Violation/); expect(err.get('smth')[0].type).to.match(/notNull Violation/);
...@@ -1403,7 +1403,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -1403,7 +1403,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(sql.indexOf('INSERT INTO "Beers" ("id","style","createdAt","updatedAt") VALUES (DEFAULT')).not.be.equal(-1); expect(sql.indexOf('INSERT INTO "Beers" ("id","style","createdAt","updatedAt") VALUES (DEFAULT')).not.be.equal(-1);
} else if (dialect === 'mssql') { } else if (dialect === 'mssql') {
expect(sql.indexOf('INSERT INTO [Beers] ([style],[createdAt],[updatedAt]) VALUES')).not.be.equal(-1); expect(sql.indexOf('INSERT INTO [Beers] ([style],[createdAt],[updatedAt]) VALUES')).not.be.equal(-1);
} else { // mysql, sqlite, mariadb } else { // mysql, sqlite
expect(sql.indexOf('INSERT INTO `Beers` (`id`,`style`,`createdAt`,`updatedAt`) VALUES (NULL')).not.be.equal(-1); expect(sql.indexOf('INSERT INTO `Beers` (`id`,`style`,`createdAt`,`updatedAt`) VALUES (NULL')).not.be.equal(-1);
} }
} }
......
...@@ -9,6 +9,7 @@ var chai = require('chai') ...@@ -9,6 +9,7 @@ var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, moment = require('moment') , moment = require('moment')
, Support = require(__dirname + '/../support') , Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect()
, DataTypes = require(__dirname + '/../../../lib/data-types') , DataTypes = require(__dirname + '/../../../lib/data-types')
, config = require(__dirname + '/../../config/config') , config = require(__dirname + '/../../config/config')
, current = Support.sequelize; , current = Support.sequelize;
...@@ -74,7 +75,7 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -74,7 +75,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
}); });
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
// Bit fields interpreted as boolean need conversion from buffer / bool. // Bit fields interpreted as boolean need conversion from buffer / bool.
// Sqlite returns the inserted value as is, and postgres really should the built in bool type instead // Sqlite returns the inserted value as is, and postgres really should the built in bool type instead
......
...@@ -22,7 +22,7 @@ var chai = require('chai') ...@@ -22,7 +22,7 @@ var chai = require('chai')
var qq = function(str) { var qq = function(str) {
if (dialect === 'postgres' || dialect === 'mssql') { if (dialect === 'postgres' || dialect === 'mssql') {
return '"' + str + '"'; return '"' + str + '"';
} else if (Support.dialectIsMySQL() || dialect === 'sqlite') { } else if (dialect === 'mysql' || dialect === 'sqlite') {
return '`' + str + '`'; return '`' + str + '`';
} else { } else {
return str; return str;
...@@ -128,9 +128,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -128,9 +128,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
expect( expect(
err.message.match(/connect ECONNREFUSED/) || err.message.match(/connect ECONNREFUSED/) ||
err.message.match(/invalid port number/) || err.message.match(/invalid port number/) ||
err.message.match(/Port should be > 0 and < 65536/) || err.message.match(/should be >=? 0 and < 65536/) ||
err.message.match(/port should be > 0 and < 65536/) ||
err.message.match(/port should be >= 0 and < 65536: 99999/) ||
err.message.match(/Login failed for user/) err.message.match(/Login failed for user/)
).to.be.ok; ).to.be.ok;
}); });
...@@ -268,7 +266,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -268,7 +266,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
// We can only test MySQL warnings when using MySQL. // We can only test MySQL warnings when using MySQL.
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
it('logs warnings when there are warnings', function() { it('logs warnings when there are warnings', function() {
var logger = sinon.spy(); var logger = sinon.spy();
var sequelize = Support.createSequelizeInstance({ var sequelize = Support.createSequelizeInstance({
...@@ -370,7 +368,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -370,7 +368,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
}); });
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
it('executes stored procedures', function() { it('executes stored procedures', function() {
var self = this; var self = this;
return self.sequelize.query(this.insertQuery).then(function() { return self.sequelize.query(this.insertQuery).then(function() {
...@@ -898,7 +896,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -898,7 +896,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
}); });
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
describe('set', function() { describe('set', function() {
it("should return an promised error if transaction isn't defined", function() { it("should return an promised error if transaction isn't defined", function() {
expect(function() { expect(function() {
......
...@@ -38,7 +38,7 @@ if (dialect !== 'sqlite') { ...@@ -38,7 +38,7 @@ if (dialect !== 'sqlite') {
}); });
}); });
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
it('handles existing timestamps', function() { it('handles existing timestamps', function() {
var NormalUser = this.sequelize.define('user', {}) var NormalUser = this.sequelize.define('user', {})
, TimezonedUser = this.sequelizeWithTimezone.define('user', {}); , TimezonedUser = this.sequelizeWithTimezone.define('user', {});
......
...@@ -166,19 +166,6 @@ var Support = { ...@@ -166,19 +166,6 @@ var Support = {
return envDialect; return envDialect;
}, },
dialectIsMySQL: function(strict) {
var envDialect = process.env.DIALECT || 'mysql';
if (strict === undefined) {
strict = false;
}
if (strict) {
return envDialect === 'mysql';
} else {
return ['mysql', 'mariadb'].indexOf(envDialect) !== -1;
}
},
getTestDialectTeaser: function(moduleName) { getTestDialectTeaser: function(moduleName) {
var dialect = this.getTestDialect(); var dialect = this.getTestDialect();
...@@ -211,10 +198,6 @@ var Support = { ...@@ -211,10 +198,6 @@ var Support = {
expectsql: function(query, expectations) { expectsql: function(query, expectations) {
var expectation = expectations[Support.sequelize.dialect.name]; var expectation = expectations[Support.sequelize.dialect.name];
if (!expectation && Support.sequelize.dialect.name === 'mariadb') {
expectation = expectations.mysql;
}
if (!expectation) { if (!expectation) {
expectation = expectations['default'] expectation = expectations['default']
.replace(/\[/g, Support.sequelize.dialect.TICK_CHAR_LEFT) .replace(/\[/g, Support.sequelize.dialect.TICK_CHAR_LEFT)
......
...@@ -93,7 +93,7 @@ describe('Sequelize', function() { ...@@ -93,7 +93,7 @@ describe('Sequelize', function() {
, config = sequelize.config , config = sequelize.config
, port; , port;
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
port = 3306; port = 3306;
} else if (dialect === 'postgres' || dialect === 'postgres-native') { } else if (dialect === 'postgres' || dialect === 'postgres-native') {
port = 5432; port = 5432;
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
var chai = require('chai') var chai = require('chai')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../../support') , Support = require(__dirname + '/../../support')
, dialect = Support.getTestDialect()
, _ = require('lodash') , _ = require('lodash')
, QueryGenerator = require('../../../../lib/dialects/mysql/query-generator'); , QueryGenerator = require('../../../../lib/dialects/mysql/query-generator');
if (Support.dialectIsMySQL()) { if (dialect === 'mysql') {
describe('[MYSQL Specific] QueryGenerator', function() { describe('[MYSQL Specific] QueryGenerator', function() {
var suites = { var suites = {
attributesToSQL: [ attributesToSQL: [
...@@ -47,7 +48,7 @@ if (Support.dialectIsMySQL()) { ...@@ -47,7 +48,7 @@ if (Support.dialectIsMySQL()) {
arguments: [{id: {type: 'INTEGER', after: 'Bar'}}], arguments: [{id: {type: 'INTEGER', after: 'Bar'}}],
expectation: {id: 'INTEGER AFTER `Bar`'} expectation: {id: 'INTEGER AFTER `Bar`'}
}, },
// New references style // New references style
{ {
arguments: [{id: {type: 'INTEGER', references: { model: 'Bar' }}}], arguments: [{id: {type: 'INTEGER', references: { model: 'Bar' }}}],
......
...@@ -72,29 +72,25 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -72,29 +72,25 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql('TEXT("tiny")', DataTypes.TEXT('tiny'), { testsql('TEXT("tiny")', DataTypes.TEXT('tiny'), {
default: 'TEXT', default: 'TEXT',
mssql: 'NVARCHAR(256)', mssql: 'NVARCHAR(256)',
mysql: 'TINYTEXT', mysql: 'TINYTEXT'
mariadb: 'TINYTEXT'
}); });
testsql('TEXT({ length: "tiny" })', DataTypes.TEXT({ length: 'tiny' }), { testsql('TEXT({ length: "tiny" })', DataTypes.TEXT({ length: 'tiny' }), {
default: 'TEXT', default: 'TEXT',
mssql: 'NVARCHAR(256)', mssql: 'NVARCHAR(256)',
mysql: 'TINYTEXT', mysql: 'TINYTEXT'
mariadb: 'TINYTEXT'
}); });
testsql('TEXT("medium")', DataTypes.TEXT('medium'), { testsql('TEXT("medium")', DataTypes.TEXT('medium'), {
default: 'TEXT', default: 'TEXT',
mssql: 'NVARCHAR(MAX)', mssql: 'NVARCHAR(MAX)',
mysql: 'MEDIUMTEXT', mysql: 'MEDIUMTEXT'
mariadb: 'MEDIUMTEXT'
}); });
testsql('TEXT("long")', DataTypes.TEXT('long'), { testsql('TEXT("long")', DataTypes.TEXT('long'), {
default: 'TEXT', default: 'TEXT',
mssql: 'NVARCHAR(MAX)', mssql: 'NVARCHAR(MAX)',
mysql: 'LONGTEXT', mysql: 'LONGTEXT'
mariadb: 'LONGTEXT'
}); });
suite('validate', function () { suite('validate', function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!