Skip to content

Commit

Permalink
Add json type (alias to TEXT)
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Sep 22, 2017
1 parent 86cc974 commit 6403d3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions models/Grammars/Grammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,10 @@ component displayname="Grammar" accessors="true" {
return "INTEGER(#column.getPrecision()#)";
}

function typeJson( column ) {
return "TEXT";
}

function typeString( column ) {
return "VARCHAR(#column.getLength()#)";
}
Expand Down
5 changes: 5 additions & 0 deletions models/Schema/Blueprint.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ component accessors="true" {
return addColumn( argumentCollection = arguments );
}

function json( name ) {
arguments.type = "json";
return addColumn( argumentCollection = arguments );
}

function tinyInteger( name, length = "" ) {
arguments.type = "tinyInteger";
return addColumn( argumentCollection = arguments );
Expand Down
8 changes: 6 additions & 2 deletions tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ component extends="testbox.system.BaseSpec" {
expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""users"" (""age"" INTEGER(2) NOT NULL)" );
} );

xit( "json", function() {
fail( "test not implemented yet" );
it( "json", function() {
var schema = getBuilder();
var blueprint = schema.create( "users", function( table ) {
table.json( "personalizations" );
}, false );
expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""users"" (""personalizations"" TEXT NOT NULL)" );
} );

xit( "longText", function() {
Expand Down

0 comments on commit 6403d3f

Please sign in to comment.