Repository navigation
Mssql can remove column with default - #4990
mickhansen merged 5 commits into
Conversation
be7659e to
76d83b7
Compare
Since lazyness is not a good reason, there is none, all schema modifying calls should really have integration tests that verify correctness via a describe call. |
There was a problem hiding this comment.
Please move tests for sql generation to test/unit instead.
|
New tests appear to fail for postgres. https://github.com/sequelize/sequelize/blob/master/lib/dialects/postgres/query-generator.js#L196 needs to be refactored to use Thank you for this contribution, the schema modification queries need a lot of love :) |
|
Thanks for the comments! I should have time to address them later in the week. |
|
As you can tell my definition of "later in the week" is somewhat liberal :)
@mickhansen I'm doing this now -- am I right in thinking that I can get rid of the assertions against count for most places where I make assertions against the result of a describe call? I don't see them being particularly valuable now we're verifying that changes to the DB have actually occurred. |
|
Should be no reason to verify the amount of sql queries run since that's really an implementation detail. |
|
@mickhansen I've finally fixed the PG tests -- it looks like they were failing because the tests were not being torn down correctly. I've added a call to dropAllSchemas in the afterEach for this test to ensure this doesn't happen -- please let me know if there's a better way. Also, I've implemented your previous suggestion of calling this.extractTableDetails in lib/dialects/postgres/query-generator.js, but this is no longer required for the tests to pass -- I'm not very familiar with Postgres so some guidance here would be helpful! (I also had to change lib/dialects/abstract/query-generator.js for extractTableDetails to work) |
There was a problem hiding this comment.
Could you make these in the form of: https://github.com/sequelize/sequelize/blob/master/test/unit/sql/select.test.js instead?
There was a problem hiding this comment.
Mind if I put this in a separate PR? This is consistent with the other pre-existing query-generator tests, and I'd like to avoid making this PR much bigger :)
There was a problem hiding this comment.
The query generator tests from the integration suite are a deprecated format, and not one we're looking to keep on using.
There was a problem hiding this comment.
Okay -- I've done this for the mssql one as I created the new file, but I don't have time to do this for the other dialects soon I'm afraid.
|
Looks good, just a single comment and i'd also love to see the commits squashed to one or two descriptive ones instead of the current 10+ |
061d291 to
dd7a59e
Compare
* this fixes Github issue sequelize#4943 * previously, calling removeColumn for a column with a defaultValue specified would cause an error -- this is because in MSSQL you have to drop the constraint before the column. See: http://stackoverflow.com/questions/8641954/how-to-drop-column-with-constraint * also added integration tests for removeColumn function
* all tests covering functionality which modifies schema now verify that the schema has actually changed, instead of just verifying against the number of logs output * remove assertions against sql count in query-interface.test * remove unused rawSelect against table in test Fixes required for new query-interface tests for PG / MySQL / MariaDB * PG: changing a column to DataTypes.FLOAT results in it being stored (and returned as) 'DOUBLE PRECISION' * ensure that test schema is torn down after each test, to avoid tests interacting with each other * remove unneeded calls to dropAllSchemas in query-interface.test.js - this is done in the afterEach call now * MySQL/MariaDB: we have to change our expectation depending on the dialect, as the DataTypes names are too inconsistent
* tableName objects have a "tableName" property, not a "table" property * addColumnQuery was broken by commit 3559ad, only on the mssql_can_remove_column_with_default branch
* as these are not integration tests * also double-quote mocha test path to ensure tests in sub-directories are run (e.g. previously, connection-manager.js was not run) see: http://stackoverflow.com/a/19902459 * remove unused beforeEach in postgres/query-generator.test.js
dd7a59e to
e3ab345
Compare
|
Thanks -- I've squashed the previous tower of commits down to 6 pretty-independent commits. Since my previous commits, a new test has been added to query-interface.test.js which uses changeColumn to add a FK reference: it('able to change column to foreign key', function() {
return this.queryInterface.changeColumn('users', 'level_id', {
type: DataTypes.INTEGER,
references: {
model: 'level',
key: 'id'
},
onUpdate: 'cascade',
onDelete: 'cascade'
}, {logging: log}).then(function() {
expect(count).to.be.equal(1);
count = 0;
});
});As far as I can tell, there's no way to verify that this FK has been added using describeTable as we now do for all the other tests -- are you aware of any other way to verify that this changeColumn has actually worked? I've left it as-is for now. Also, do you have any comment re: my query on this.extractTableDetails above? Thanks! |
|
quoteTable/extractTableDetails should be required on most things, if the tests arent failing it's because we have insufficient schema tests for those cases. If it's not part of describeTable there's likely not a good way to verify this at the moment. |
…column_with_default Mssql can remove column with default
|
Thanks! |
|
Released in |
specified would cause an error -- this is because in MSSQL you have
to drop the constraint before the column. See:
http://stackoverflow.com/questions/8641954/how-to-drop-column-with-constraint
I've verified that all the MSSQL tests pass, but haven't yet run the tests against other vendors -- will attempt to do that soon.
I think this is otherwise mostly ready, but there are some rough edges I have some questions about:
This is my first non-trivial PR to Sequelize, so let me know if I've missed anything!