From 35b7d83d913ba24bc6503934eddc8b730f37bac7 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 2 Sep 2017 21:31:25 -0600 Subject: [PATCH] Add medium and long text types --- models/Grammars/Grammar.cfc | 8 ++++++++ models/Schema/Blueprint.cfc | 10 ++++++++++ tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/models/Grammars/Grammar.cfc b/models/Grammars/Grammar.cfc index 01cabfce..48ad41e5 100644 --- a/models/Grammars/Grammar.cfc +++ b/models/Grammars/Grammar.cfc @@ -822,6 +822,14 @@ component displayname="Grammar" accessors="true" { return "TEXT"; } + function typeLongText( column ) { + return "TEXT"; + } + + function typeMediumText( column ) { + return "TEXT"; + } + function typeString( column ) { return "VARCHAR(#column.getLength()#)"; } diff --git a/models/Schema/Blueprint.cfc b/models/Schema/Blueprint.cfc index 5e29aa3d..23c78c30 100644 --- a/models/Schema/Blueprint.cfc +++ b/models/Schema/Blueprint.cfc @@ -123,6 +123,16 @@ component accessors="true" { return addColumn( argumentCollection = arguments ); } + function longText( name ) { + arguments.type = "longText"; + return addColumn( argumentCollection = arguments ); + } + + function mediumText( name ) { + arguments.type = "mediumText"; + return addColumn( argumentCollection = arguments ); + } + function tinyInteger( name, length = "" ) { arguments.type = "tinyInteger"; return addColumn( argumentCollection = arguments ); diff --git a/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc b/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc index d22bf2d8..96a0f8fa 100644 --- a/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc +++ b/tests/specs/Schema/SchemaBuilder+GrammarSpec.cfc @@ -218,8 +218,12 @@ component extends="testbox.system.BaseSpec" { expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""users"" (""personalizations"" TEXT NOT NULL)" ); } ); - xit( "longText", function() { - fail( "test not implemented yet" ); + it( "longText", function() { + var schema = getBuilder(); + var blueprint = schema.create( "posts", function( table ) { + table.longText( "body" ); + }, false ); + expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""posts"" (""body"" TEXT NOT NULL)" ); } ); xit( "mediumIncrements", function() { @@ -230,8 +234,12 @@ component extends="testbox.system.BaseSpec" { fail( "test not implemented yet" ); } ); - xit( "mediumText", function() { - fail( "test not implemented yet" ); + it( "mediumText", function() { + var schema = getBuilder(); + var blueprint = schema.create( "posts", function( table ) { + table.mediumText( "body" ); + }, false ); + expect( blueprint.toSql() ).toBeWithCase( "CREATE TABLE ""posts"" (""body"" TEXT NOT NULL)" ); } ); xit( "morphs", function() {