Permalink
Browse files

Merge pull request #16 from mhuggins/0cfd9e25d95581002b85f0190a6c27ac…

…8a3b0cb2

Respect column length attribute
  • Loading branch information...
kunklejr committed Jun 9, 2012
2 parents e16bfda + 0cfd9e2 commit 9769c357dad3ab966fad0162f77e0ccf7ccfedb3
Showing with 10 additions and 2 deletions.
  1. +4 −1 lib/driver/base.js
  2. +6 −1 lib/driver/pg.js
View
@@ -36,7 +36,10 @@ module.exports = Base = Class.extend({
},
createColumnDef: function(name, spec, options) {
- return [name, this.mapDataType(spec.type), this.createColumnConstraint(spec, options)].join(' ');
+ var type = this.mapDataType(spec.type);
+ var len = spec.length ? util.format('(%s)', spec.length) : '';
+ var constraint = this.createColumnConstraint(spec, options);
+ return [name, type, len, constraint].join(' ');
},
createMigrationsTable: function(callback) {
View
@@ -11,6 +11,7 @@ var PgDriver = Base.extend({
this.connection = connection;
this.connection.connect();
},
+
startMigration: function(cb){
this.runSql('BEGIN;', function() { cb()});
},
@@ -20,8 +21,12 @@ var PgDriver = Base.extend({
},
createColumnDef: function(name, spec, options) {
- return [name, spec.autoIncrement ? '' : this.mapDataType(spec.type), this.createColumnConstraint(spec, options)].join(' ');
+ var type = spec.autoIncrement ? '' : this.mapDataType(spec.type);
+ var len = spec.length ? util.format('(%s)', spec.length) : '';
+ var constraint = this.createColumnConstraint(spec, options);
+ return [name, type, len, constraint].join(' ');
},
+
mapDataType: function(str) {
switch(str) {
case type.STRING:

0 comments on commit 9769c35

Please sign in to comment.