Comparing version 2.3.1 to 2.3.2
@@ -408,3 +408,3 @@ "use strict"; | ||
let changes = { | ||
field: { name: joinColumn.name, type: 'integer', unsigned: true, nullable: true }, | ||
field: { name: joinColumn.name, type: 'integer', unsigned: true, nullable: (typeof joinColumn.nullable === 'boolean' ? joinColumn.nullable : true) }, | ||
foreign: createForeign(mapping, property, targetMapping) | ||
@@ -411,0 +411,0 @@ }; |
@@ -8,2 +8,4 @@ "use strict"; | ||
const new_1 = require("../resource/entity/snapshot/new"); | ||
const book_1 = require("../resource/entity/book/book"); | ||
const publisher_1 = require("../resource/entity/book/publisher"); | ||
function getWetland(entities) { | ||
@@ -41,2 +43,12 @@ let wetland = new Wetland_1.Wetland({ | ||
}); | ||
describe('diff(jc): create join column', () => { | ||
it('Should be able to create a non null foreign key', () => { | ||
let oldMapping = getMapping([]), newMapping = getMapping([book_1.Book, publisher_1.Publisher]); | ||
let wetland = getWetland(), snapshotManager = wetland.getSnapshotManager(), schemaBuilder = new SchemaBuilder_1.SchemaBuilder(wetland.getManager()); | ||
let diff = snapshotManager.diff(oldMapping, newMapping); | ||
let sqlStatement = schemaBuilder.process(diff).getSQL().split('\n'); | ||
chai_1.assert.equal(sqlStatement[0], 'create table `publisher` (`id` int unsigned not null auto_increment primary key, `name` varchar(24) not null);'); | ||
chai_1.assert.equal(sqlStatement[1], 'create table `book` (`id` int unsigned not null auto_increment primary key, `name` varchar(24) not null, `publisher_id` int unsigned not null);'); | ||
}); | ||
}); | ||
}); |
@@ -0,1 +1,11 @@ | ||
<a name="2.3.2"></a> | ||
## [2.3.2](https://github.com/SpoonX/wetland/compare/v2.3.1...v2.3.2) (2017-08-21) | ||
### Bug Fixes | ||
* **SnapshotManager:** use nullable value for joinColumn from mapping ([ce84a91](https://github.com/SpoonX/wetland/commit/ce84a91)) | ||
<a name="2.3.1"></a> | ||
@@ -2,0 +12,0 @@ ## [2.3.1](https://github.com/SpoonX/wetland/compare/v2.3.0...v2.3.1) (2017-08-09) |
{ | ||
"name": "wetland", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "A modern object-relational mapper (ORM) for node.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -519,3 +519,3 @@ import * as fs from 'fs'; | ||
let changes = { | ||
field : {name: joinColumn.name, type: 'integer', unsigned: true, nullable: true}, | ||
field : {name: joinColumn.name, type: 'integer', unsigned: true, nullable: (typeof joinColumn.nullable === 'boolean' ? joinColumn.nullable : true)}, | ||
foreign: createForeign(mapping, property, targetMapping) | ||
@@ -522,0 +522,0 @@ }; |
@@ -7,2 +7,4 @@ import {assert} from 'chai'; | ||
import newEntities from '../resource/entity/snapshot/new'; | ||
import {Book} from '../resource/entity/book/book'; | ||
import {Publisher} from '../resource/entity/book/publisher'; | ||
@@ -52,2 +54,19 @@ function getWetland(entities?): Wetland { | ||
}); | ||
describe('diff(jc): create join column', () => { | ||
it('Should be able to create a non null foreign key', () => { | ||
let oldMapping = getMapping([]), | ||
newMapping = getMapping([Book, Publisher]); | ||
let wetland = getWetland(), | ||
snapshotManager = wetland.getSnapshotManager(), | ||
schemaBuilder = new SchemaBuilder(wetland.getManager()); | ||
let diff = snapshotManager.diff(oldMapping, newMapping); | ||
let sqlStatement = schemaBuilder.process(diff).getSQL().split('\n'); | ||
assert.equal(sqlStatement[0], 'create table `publisher` (`id` int unsigned not null auto_increment primary key, `name` varchar(24) not null);'); | ||
assert.equal(sqlStatement[1], 'create table `book` (`id` int unsigned not null auto_increment primary key, `name` varchar(24) not null, `publisher_id` int unsigned not null);'); | ||
}) | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3070206
364
30592