-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MySQL has an unfortunate syntax that requires the definition to be repeated. We may be able to discover this from the table, but right now we're punting and asking the user to redeclare the column definition. Fun fact, in MySQL, renameColumn will let you modifyColumn at the same time.
- Loading branch information
Showing
7 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
component extends="testbox.system.BaseSpec" { | ||
|
||
function run() { | ||
describe( "schema builder + oracle grammar", function() { | ||
describe( "rename columns", function() { | ||
it( "renames a column", function() { | ||
var schema = getBuilder(); | ||
var blueprint = schema.alter( "users", function( table ) { | ||
table.renameColumn( "name", table.string( "username" ) ); | ||
}, {}, false ); | ||
var statements = blueprint.toSql(); | ||
expect( statements ).toBeArray(); | ||
expect( statements ).toHaveLength( 1 ); | ||
expect( statements[ 1 ] ).toBeWithCase( "ALTER TABLE ""USERS"" RENAME COLUMN ""NAME"" TO ""USERNAME""" ); | ||
} ); | ||
|
||
it( "renames multiple columns", function() { | ||
var schema = getBuilder(); | ||
var blueprint = schema.alter( "users", function( table ) { | ||
table.renameColumn( "name", table.string( "username" ) ); | ||
table.renameColumn( "purchase_date", table.timestamp( "purchased_at" ).nullable() ); | ||
}, {}, false ); | ||
var statements = blueprint.toSql(); | ||
expect( statements ).toBeArray(); | ||
expect( statements ).toHaveLength( 2 ); | ||
expect( statements[ 1 ] ).toBeWithCase( "ALTER TABLE ""USERS"" RENAME COLUMN ""NAME"" TO ""USERNAME""" ); | ||
expect( statements[ 2 ] ).toBeWithCase( "ALTER TABLE ""USERS"" RENAME COLUMN ""PURCHASE_DATE"" TO ""PURCHASED_AT""" ); | ||
} ); | ||
} ); | ||
} ); | ||
} | ||
|
||
private function getBuilder() { | ||
var grammar = getMockBox() | ||
.createMock( "qb.models.Grammars.OracleGrammar" ); | ||
var builder = getMockBox().createMock( "qb.models.Schema.SchemaBuilder" ) | ||
.init( grammar ); | ||
return builder; | ||
} | ||
|
||
} |