cli
cli copied to clipboard
Add db:create and db:drop support for MariaDB
Pull Request check-list
Please make sure to review and check all of these items:
- [ ] Does
npm run testpass with this change (including linting)? No, but linting issues are unrelated to my change. - [x] Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
- [ ] Have you added new tests to prevent regressions? I have db drop and create tests that pass. Some of the other pre-existing tests do not pass locally for me.
- [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
Description of change
Adds support for db:create and db:drop for MariaDB. This uses the same code block as MySQL since they are compatible.
I can push up the tests if you want. It's just an extra if (Support.dialectIsMariaDB()) { in the db-create and db-drop test files.
Closes https://github.com/sequelize/cli/issues/1236
Hi, thanks for submitting this PR. And our apologies for the late response. Are you still willing to add some tests to this?
I was trying to fix this problem but I have found inconsistencies in how sequelize returns the list of tables for a database schema. These inconsistencies cause failures in tests which then needs special handling making them a bit brittle.
sequelize returns an array of strings with table names for mysql, pgsql and sqlite while it returns an array of objects for mariadb and mssql.
// `mysql`, `pgsql` and `sqlite`
showTableNames() -> ['tableA', 'tableB', ...]
// `mariadb` and `mssql`
showTableNames() -> [{tableName: 'tableA', schema: 'schemaX}, {tableName: 'tableB', schema: 'scehmaX}, ...]
So, I could write tests to handle this inconsistencies thus making the cli handle create/drop for mariadb, but I am wondering if this issue should really be fixed in sequelize itself by normalising the API across all the dialects. Also, I am wondering how tests for mssql are passing. I do not have a MSSQL server I can test against so my doubts remain.
EDIT:
I have tried to run the tests against a MSSQL database using the docker image provided by Microsoft and indeed the tests are failing due to the same reason that the returned list of table names is a list of objects and not a simple list of strings (names).
I was trying to fix this problem but I have found inconsistencies in how
sequelizereturns the list of tables for a database schema. These inconsistencies cause failures in tests which then needs special handling making them a bit brittle.
sequelizereturns an array of strings with table names formysql,pgsqlandsqlitewhile it returns an array of objects formariadbandmssql.// `mysql`, `pgsql` and `sqlite` showTableNames() -> ['tableA', 'tableB', ...] // `mariadb` and `mssql` showTableNames() -> [{tableName: 'tableA', schema: 'schemaX}, {tableName: 'tableB', schema: 'scehmaX}, ...]So, I could write tests to handle this inconsistencies thus making the
clihandlecreate/dropformariadb, but I am wondering if this issue should really be fixed insequelizeitself by normalising the API across all the dialects. Also, I am wondering how tests formssqlare passing. I do not have a MSSQL server I can test against so my doubts remain.EDIT:
I have tried to run the tests against a MSSQL database using the docker image provided by Microsoft and indeed the tests are failing due to the same reason that the returned list of table names is a list of objects and not a simple list of strings (names).
Hi. Thanks for looking into this! It would indeed be good if it is normalized in sequelize itself, but if a dialect does not support schemas it would be prettier to return only the table names. So I don't think a fix like this would be the best solution. I think we should just accommodate for both options. I will work on update the CI to include the same dialects as sequelize itself and then maybe we can work together on fixing the failing tests?
Hi, just want to check if there will be an update on reviewing this mariadb support for create/drop action. Thank you.
For God's sake, someone please, accept this MR. It's just a new case to the switch. It can't break anything since the syntax for mysql and mariadb is the same!
Furthermore db-create.test.js Tests indeed both (mysql and mariadb) since: if (Support.dialectIsMySQL()) {
Refers to index.js: Support.dialectIsMySQL: function (strict) { that returns return ['mysql', 'mariadb'].indexOf(envDialect) !== -1; Which is true in this case.