From 1fb25952a00007c84a59f92567e736f5b023009d Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 13:04:24 -0600 Subject: [PATCH 1/6] BoxLang Certification Some variable names have changed to support the certification. You shouldn't see any problems unless you have custom QueryBuilders that are extending from the built-in models. BREAKING CHANGE: Internal variable name changes --- .github/workflows/cron.yml | 9 +- .github/workflows/pr.yml | 9 +- .github/workflows/prerelease.yml | 9 +- .github/workflows/release.yml | 9 +- box.json | 5 +- models/Grammars/BaseGrammar.cfc | 32 +-- models/Grammars/MySQLGrammar.cfc | 12 +- models/Grammars/OracleGrammar.cfc | 22 +- models/Grammars/PostgresGrammar.cfc | 16 +- models/Grammars/SQLiteGrammar.cfc | 22 +- models/Grammars/SqlServerGrammar.cfc | 28 +-- models/Query/QueryBuilder.cfc | 50 ++--- models/Query/QueryUtils.cfc | 31 +-- models/SQLCommenter/SQLCommenter.cfc | 2 +- models/Schema/Blueprint.cfc | 22 +- models/Schema/Column.cfc | 24 +-- models/Schema/TableIndex.cfc | 10 +- server.json | 2 +- tests/index.cfm | 191 +++++++++++++++++- tests/resources/AbstractQueryBuilderSpec.cfc | 20 +- tests/resources/AbstractSchemaBuilderSpec.cfc | 6 +- .../Query/Abstract/QueryDebuggingSpec.cfc | 9 +- .../Query/Abstract/QueryExecutionSpec.cfc | 46 ++++- tests/specs/Query/Abstract/QueryUtilsSpec.cfc | 13 +- tests/specs/Query/MySQLQueryBuilderSpec.cfc | 4 +- tests/specs/Query/OracleQueryBuilderSpec.cfc | 4 +- .../specs/Query/PostgresQueryBuilderSpec.cfc | 4 +- tests/specs/Query/SQLiteQueryBuilderSpec.cfc | 4 +- .../specs/Query/SqlServerQueryBuilderSpec.cfc | 4 +- 29 files changed, 431 insertions(+), 188 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 7c850b5f..46f83a4b 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "lucee@be", "adobe@2018", "adobe@2021", "adobe@be"] + cfengine: ["lucee@5", "lucee@be", "adobe@2018", "adobe@2021", "adobe@2023", "adobe@be", "boxlang@be"] javaVersion: ["openjdk8", "openjdk11"] fullNull: ["true", "false"] steps: @@ -32,7 +32,12 @@ jobs: box install - name: Start server - run: box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} --noSaveSettings + run: | + box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} --noSaveSettings + if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box run-script bx-modules:install + box server restart + fi - name: Run TestBox Tests env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e195451c..220b0bc5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021"] + cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -39,7 +39,12 @@ jobs: box install - name: Start server - run: box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + run: | + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box run-script bx-modules:install + box server restart + fi - name: Run TestBox Tests env: diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index f01cbfa0..9969ad02 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021"] + cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -33,7 +33,12 @@ jobs: box install - name: Start server - run: box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + run: | + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box run-script bx-modules:install + box server restart + fi - name: Run TestBox Tests env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0af2588d..61b533ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021"] + cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -34,7 +34,12 @@ jobs: box install - name: Start server - run: box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + run: | + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box run-script bx-modules:install + box server restart + fi - name: Run TestBox Tests env: diff --git a/box.json b/box.json index d8de7c3d..0a1534d5 100644 --- a/box.json +++ b/box.json @@ -9,7 +9,8 @@ "generateAPIDocs":"touch .tmp && rm .tmp --recurse --force && docbox generate mapping=qb excludes=test|ModuleConfig strategy-outputDir=.tmp/apidocs strategy-projectTitle=qb", "commitAPIDocs":"run-script generateAPIDocs && !git add docs/apidocs/* && !git commit -m 'Updated API Docs'", "format":"cfformat run models/**/*.cfc,tests/resources/**/*.cfc,tests/specs/**/*.cfc --overwrite", - "format:check":"cfformat check models/**/*.cfc,tests/resources/**/*.cfc,tests/specs/**/*.cfc" + "format:check":"cfformat check models/**/*.cfc,tests/resources/**/*.cfc,tests/specs/**/*.cfc", + "bx-modules:install":"install bx-compat-cfml@be,bx-esapi" }, "repository":{ "type":"git", @@ -36,7 +37,7 @@ "cbpaginator":"^2.4.0" }, "devDependencies":{ - "testbox":"be" + "testbox":"^6.0.0" }, "installPaths":{ "testbox":"testbox/", diff --git a/models/Grammars/BaseGrammar.cfc b/models/Grammars/BaseGrammar.cfc index 7e68f320..c65bfe52 100644 --- a/models/Grammars/BaseGrammar.cfc +++ b/models/Grammars/BaseGrammar.cfc @@ -39,7 +39,7 @@ component displayname="Grammar" accessors="true" singleton { "commonTables", "aggregate", "columns", - "from", + "tableName", "joins", "wheres", "groups", @@ -267,8 +267,8 @@ component displayname="Grammar" accessors="true" singleton { * * @return string */ - private string function compileFrom( required QueryBuilder query, required any from ) { - var fullTable = arguments.from; + private string function compileTableName( required QueryBuilder query, required any tableName ) { + var fullTable = arguments.tableName; if ( query.getAlias() != "" ) { fullTable &= " #query.getAlias()#"; } @@ -817,7 +817,7 @@ component displayname="Grammar" accessors="true" singleton { .toList( ", " ) & ")"; } ) .toList( ", " ); - return trim( "INSERT INTO #wrapTable( query.getFrom() )# (#columnsString#) VALUES #placeholderString#" ); + return trim( "INSERT INTO #wrapTable( query.getTableName() )# (#columnsString#) VALUES #placeholderString#" ); } /** @@ -867,7 +867,7 @@ component displayname="Grammar" accessors="true" singleton { .toList( ", " ); return trim( - compileCommonTables( query, query.getCommonTables() ) & " INSERT INTO #wrapTable( arguments.query.getFrom() )# (#columnsString#) #compileSelect( arguments.source )#" + compileCommonTables( query, query.getCommonTables() ) & " INSERT INTO #wrapTable( arguments.query.getTableName() )# (#columnsString#) #compileSelect( arguments.source )#" ); } @@ -901,7 +901,7 @@ component displayname="Grammar" accessors="true" singleton { } ) .toList( ", " ); - var updateStatement = "UPDATE #wrapTable( query.getFrom() )#"; + var updateStatement = "UPDATE #wrapTable( query.getTableName() )#"; if ( !arguments.query.getJoins().isEmpty() ) { updateStatement &= " " & compileJoins( arguments.query, arguments.query.getJoins() ); @@ -923,7 +923,7 @@ component displayname="Grammar" accessors="true" singleton { if ( !arguments.query.getReturning().isEmpty() ) { throw( type = "UnsupportedOperation", message = "This grammar does not support a RETURNING clause" ); } - return trim( "DELETE FROM #wrapTable( query.getFrom() )# #compileWheres( query, query.getWheres() )#" ); + return trim( "DELETE FROM #wrapTable( query.getTableName() )# #compileWheres( query, query.getWheres() )#" ); } /** @@ -1035,7 +1035,7 @@ component displayname="Grammar" accessors="true" singleton { // Quick check to see if we should bother to use a regex to look for a table alias if ( parts.table.find( " " ) ) { var matches = reFindNoCase( - "(.*?)(?:\s(?:AS\s){0,1})([^\)]+)$", + "(.*?)(?:\s(?:AS\s)*)([^\)]+)$", parts.table, 1, true @@ -1226,15 +1226,15 @@ component displayname="Grammar" accessors="true" singleton { } function generateNullConstraint( column ) { - return column.getNullable() ? "" : "NOT NULL"; + return column.getIsNullable() ? "" : "NOT NULL"; } function generateUniqueConstraint( column, blueprint ) { - return column.getUnique() ? "UNIQUE" : ""; + return column.getIsUnique() ? "UNIQUE" : ""; } function modifyUnsigned( column ) { - return column.getUnsigned() ? "UNSIGNED" : ""; + return column.getIsUnsigned() ? "UNSIGNED" : ""; } function generateComputed( column ) { @@ -1252,14 +1252,14 @@ component displayname="Grammar" accessors="true" singleton { } function generateDefault( column ) { - if ( column.getDefault() == "" ) { + if ( column.getDefaultValue() == "" ) { return ""; } return "DEFAULT #wrapDefaultType( column )#"; } function generateComment( column ) { - return column.getComment() != "" ? "COMMENT '#column.getComment()#'" : ""; + return column.getCommentValue() != "" ? "COMMENT '#column.getCommentValue()#'" : ""; } function compileAddComment( blueprint, commandParameters ) { @@ -1268,7 +1268,7 @@ component displayname="Grammar" accessors="true" singleton { "COMMENT ON COLUMN", wrapColumn( commandParameters.table & "." & commandParameters.column.getName() ), "IS", - "'" & commandParameters.column.getComment() & "'" + "'" & commandParameters.column.getCommentValue() & "'" ], " " ); @@ -1743,8 +1743,8 @@ component displayname="Grammar" accessors="true" singleton { "CONSTRAINT #wrapValue( index.getName() )#", "FOREIGN KEY (#keys#)", "REFERENCES #wrapTable( index.getTable() )# (#references#)", - "ON UPDATE #uCase( index.getOnUpdate() )#", - "ON DELETE #uCase( index.getOnDelete() )#" + "ON UPDATE #uCase( index.getOnUpdateAction() )#", + "ON DELETE #uCase( index.getOnDeleteAction() )#" ], " " ); diff --git a/models/Grammars/MySQLGrammar.cfc b/models/Grammars/MySQLGrammar.cfc index 2f8da308..a06994d8 100644 --- a/models/Grammars/MySQLGrammar.cfc +++ b/models/Grammars/MySQLGrammar.cfc @@ -149,7 +149,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { var cteClause = query.getCommonTables().isEmpty() ? "" : " #compileCommonTables( query, query.getCommonTables() )#"; - return "INSERT INTO #wrapTable( arguments.query.getFrom() )# (#columnsString#)#cteClause# #compileSelect( arguments.source )#"; + return "INSERT INTO #wrapTable( arguments.query.getTableName() )# (#columnsString#)#cteClause# #compileSelect( arguments.source )#"; } public string function compileUpsert( @@ -199,10 +199,10 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { function generateDefault( column ) { if ( - column.getDefault() == "" && + column.getDefaultValue() == "" && column.getType().findNoCase( "TIMESTAMP" ) > 0 ) { - if ( column.getNullable() ) { + if ( column.getIsNullable() ) { return "NULL DEFAULT NULL"; } else { column.withCurrent(); @@ -214,12 +214,12 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { function wrapDefaultType( column ) { switch ( column.getType() ) { case "boolean": - return column.getDefault() ? 1 : 0; + return column.getDefaultValue() ? 1 : 0; case "char": case "string": - return "'#column.getDefault()#'"; + return "'#column.getDefaultValue()#'"; default: - return column.getDefault(); + return column.getDefaultValue(); } } diff --git a/models/Grammars/OracleGrammar.cfc b/models/Grammars/OracleGrammar.cfc index 3b92b298..10f7130c 100644 --- a/models/Grammars/OracleGrammar.cfc +++ b/models/Grammars/OracleGrammar.cfc @@ -76,9 +76,9 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { private string function compileOracleLockType( required query, required string sql ) { switch ( arguments.query.getLockType() ) { case "shared": - return "LOCK TABLE #wrapTable( arguments.query.getFrom() )# IN SHARE MODE NOWAIT; #arguments.sql#"; + return "LOCK TABLE #wrapTable( arguments.query.getTableName() )# IN SHARE MODE NOWAIT; #arguments.sql#"; case "custom": - return "LOCK TABLE #wrapTable( arguments.query.getFrom() )# IN #arguments.query.getLockValue()# MODE NOWAIT; #arguments.sql#"; + return "LOCK TABLE #wrapTable( arguments.query.getTableName() )# IN #arguments.query.getLockValue()# MODE NOWAIT; #arguments.sql#"; case "none": case "nolock": default: @@ -126,7 +126,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { var placeholderString = values .map( function( valueArray ) { - return "INTO #wrapTable( query.getFrom() )# (#columnsString#) VALUES (" & valueArray + return "INTO #wrapTable( query.getTableName() )# (#columnsString#) VALUES (" & valueArray .map( function( item ) { if ( getUtils().isExpression( item ) ) { return item.getSQL(); @@ -231,7 +231,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } var updateStatement = updateList == "" ? "" : " WHEN MATCHED THEN UPDATE SET #updateList#"; - return "MERGE INTO #wrapTable( arguments.qb.getFrom() )# ""QB_TARGET"" USING (#placeholderString#) ""QB_SRC"" ON #constraintString##updateStatement# WHEN NOT MATCHED THEN INSERT (#columnsString#) VALUES (#valuesString#)"; + return "MERGE INTO #wrapTable( arguments.qb.getTableName() )# ""QB_TARGET"" USING (#placeholderString#) ""QB_SRC"" ON #constraintString##updateStatement# WHEN NOT MATCHED THEN INSERT (#columnsString#) VALUES (#valuesString#)"; } /** @@ -447,7 +447,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } function generateNullConstraint( column ) { - return ( column.getNullable() || column.getComputedType() != "none" ) ? "" : "NOT NULL"; + return ( column.getIsNullable() || column.getComputedType() != "none" ) ? "" : "NOT NULL"; } function modifyUnsigned( column ) { @@ -484,14 +484,14 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } function generateUniqueConstraint( column, blueprint ) { - if ( column.getUnique() ) { + if ( column.getIsUnique() ) { blueprint.unique( [ column.getName() ] ); } return ""; } function generateComment( column, blueprint ) { - if ( column.getComment() != "" ) { + if ( column.getCommentValue() != "" ) { blueprint.addCommand( "addComment", { table: blueprint.getTable(), column: column } ); } return ""; @@ -500,12 +500,12 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { function wrapDefaultType( column ) { switch ( column.getType() ) { case "boolean": - return column.getDefault() ? 1 : 0; + return column.getDefaultValue() ? 1 : 0; case "char": case "string": - return "'#column.getDefault()#'"; + return "'#column.getDefaultValue()#'"; default: - return column.getDefault(); + return column.getDefaultValue(); } } @@ -654,7 +654,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { "CONSTRAINT #wrapValue( index.getName() )#", "FOREIGN KEY (#keys#)", "REFERENCES #wrapTable( index.getTable() )# (#references#)", - "ON DELETE #uCase( index.getOnDelete() )#" + "ON DELETE #uCase( index.getOnDeleteAction() )#" ], " " ); diff --git a/models/Grammars/PostgresGrammar.cfc b/models/Grammars/PostgresGrammar.cfc index b13e35f9..02fbf534 100644 --- a/models/Grammars/PostgresGrammar.cfc +++ b/models/Grammars/PostgresGrammar.cfc @@ -103,7 +103,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } ) .toList( ", " ); - var updateStatement = "UPDATE #wrapTable( query.getFrom() )# SET #updateList#"; + var updateStatement = "UPDATE #wrapTable( query.getTableName() )# SET #updateList#"; var joins = arguments.query.getJoins(); @@ -153,7 +153,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { .map( wrapColumn ) .toList( ", " ); var returningClause = returningColumns != "" ? " RETURNING #returningColumns#" : ""; - return trim( "DELETE FROM #wrapTable( query.getFrom() )# #compileWheres( query, query.getWheres() )##returningClause#" ); + return trim( "DELETE FROM #wrapTable( query.getTableName() )# #compileWheres( query, query.getWheres() )##returningClause#" ); } public string function compileUpsert( @@ -250,7 +250,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } function generateUniqueConstraint( column ) { - return column.getUnique() ? "UNIQUE" : ""; + return column.getIsUnique() ? "UNIQUE" : ""; } function modifyUnsigned( column ) { @@ -270,7 +270,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } function generateComment( column, blueprint ) { - if ( column.getComment() != "" ) { + if ( column.getCommentValue() != "" ) { blueprint.addCommand( "addComment", { table: blueprint.getTable(), column: column } ); } return ""; @@ -279,12 +279,12 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { function wrapDefaultType( column ) { switch ( column.getType() ) { case "boolean": - return uCase( column.getDefault() ); + return uCase( column.getDefaultValue() ); case "char": case "string": - return "'#column.getDefault()#'"; + return "'#column.getDefaultValue()#'"; default: - return column.getDefault(); + return column.getDefaultValue(); } } @@ -323,7 +323,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { generateType( commandParameters.to, blueprint ) & ",", "ALTER COLUMN", wrapColumn( commandParameters.to.getName() ), - commandParameters.to.getNullable() ? "DROP" : "SET", + commandParameters.to.getIsNullable() ? "DROP" : "SET", "NOT NULL" ], function( item ) { diff --git a/models/Grammars/SQLiteGrammar.cfc b/models/Grammars/SQLiteGrammar.cfc index 9012d10d..d1b0929f 100644 --- a/models/Grammars/SQLiteGrammar.cfc +++ b/models/Grammars/SQLiteGrammar.cfc @@ -120,10 +120,10 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } ) .toList( ", " ); - var updateStatement = "UPDATE #wrapTable( query.getFrom() )#"; + var updateStatement = "UPDATE #wrapTable( query.getTableName() )#"; var joinStatement = ""; if ( !arguments.query.getJoins().isEmpty() ) { - joinStatement = " FROM #wrapTable( query.getFrom() )# " & compileJoins( + joinStatement = " FROM #wrapTable( query.getTableName() )# " & compileJoins( arguments.query, arguments.query.getJoins() ); @@ -155,7 +155,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { .map( wrapColumn ) .toList( ", " ); var returningClause = returningColumns != "" ? " RETURNING #returningColumns#" : ""; - return trim( "DELETE FROM #wrapTable( query.getFrom() )# #compileWheres( query, query.getWheres() )##returningClause#" ); + return trim( "DELETE FROM #wrapTable( query.getTableName() )# #compileWheres( query, query.getWheres() )##returningClause#" ); } public string function compileUpsert( @@ -221,12 +221,12 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { function wrapDefaultType( column ) { switch ( column.getType() ) { case "boolean": - return column.getDefault() ? 1 : 0; + return column.getDefaultValue() ? 1 : 0; case "char": case "string": - return "'#column.getDefault()#'"; + return "'#column.getDefaultValue()#'"; default: - return column.getDefault(); + return column.getDefaultValue(); } } @@ -353,15 +353,15 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { return "CHECK (#wrapColumn( column.getName() )# IN (#values#))"; } - return column.getUnique() ? "UNIQUE" : ""; + return column.getIsUnique() ? "UNIQUE" : ""; } function generateDefault( column ) { if ( - column.getDefault() == "" && + column.getDefaultValue() == "" && column.getType().findNoCase( "TIMESTAMP" ) > 0 ) { - if ( column.getNullable() ) { + if ( column.getIsNullable() ) { return ""; } else { column.withCurrent(); @@ -534,8 +534,8 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { [ "FOREIGN KEY (#keys#)", "REFERENCES #wrapTable( index.getTable() )# (#references#)", - "ON UPDATE #uCase( index.getOnUpdate() )#", - "ON DELETE #uCase( index.getOnDelete() )#" + "ON UPDATE #uCase( index.getOnUpdateAction() )#", + "ON DELETE #uCase( index.getOnDeleteAction() )#" ], " " ); diff --git a/models/Grammars/SqlServerGrammar.cfc b/models/Grammars/SqlServerGrammar.cfc index 2828a20b..ca3d13b8 100644 --- a/models/Grammars/SqlServerGrammar.cfc +++ b/models/Grammars/SqlServerGrammar.cfc @@ -12,7 +12,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { "commonTables", "aggregate", "columns", - "from", + "tableName", "lockType", "joins", "wheres", @@ -79,7 +79,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { } ) .toList( ", " ); return trim( - "INSERT INTO #wrapTable( query.getFrom() )# (#columnsString#)#returningClause# VALUES #placeholderString#" + "INSERT INTO #wrapTable( query.getTableName() )# (#columnsString#)#returningClause# VALUES #placeholderString#" ); } @@ -280,11 +280,11 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { .toList( ", " ); var updateTable = ""; - if ( !getUtils().isExpression( query.getFrom() ) ) { - var parts = explodeTable( query.getFrom() ); + if ( !getUtils().isExpression( query.getTableName() ) ) { + var parts = explodeTable( query.getTableName() ); updateTable = parts.alias.len() ? wrapAlias( parts.alias ) : wrapTable( parts.table ); } else { - updateTable = query.getFrom().getSql(); + updateTable = query.getTableName().getSql(); } var updateStatement = arrayToList( arrayFilter( @@ -321,7 +321,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { } return trim( - updateStatement & " FROM #wrapTable( query.getFrom() )# " & compileJoins( + updateStatement & " FROM #wrapTable( query.getTableName() )# " & compileJoins( arguments.query, arguments.query.getJoins() ) & returningClause & " " & compileWheres( query, query.getWheres() ) @@ -349,7 +349,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { } ) .toList( ", " ); var returningClause = returningColumns != "" ? " OUTPUT #returningColumns#" : ""; - return trim( "DELETE FROM #wrapTable( query.getFrom() )##returningClause# #compileWheres( query, query.getWheres() )#" ); + return trim( "DELETE FROM #wrapTable( query.getTableName() )##returningClause# #compileWheres( query, query.getWheres() )#" ); } public string function compileUpsert( @@ -429,7 +429,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { var returningClause = returningColumns != "" ? " OUTPUT #returningColumns#" : ""; - return "MERGE #wrapTable( arguments.qb.getFrom() )# AS [qb_target] USING #sourceString# ON #constraintString##updateStatement# WHEN NOT MATCHED BY TARGET THEN INSERT (#columnsString#) VALUES (#columnsString#)#deleteStatement##returningClause#;"; + return "MERGE #wrapTable( arguments.qb.getTableName() )# AS [qb_target] USING #sourceString# ON #constraintString##updateStatement# WHEN NOT MATCHED BY TARGET THEN INSERT (#columnsString#) VALUES (#columnsString#)#deleteStatement##returningClause#;"; } function generateType( column, blueprint ) { @@ -440,7 +440,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { } function generateNullConstraint( column ) { - return ( column.getNullable() || column.getComputedType() != "none" ) ? "" : "NOT NULL"; + return ( column.getIsNullable() || column.getComputedType() != "none" ) ? "" : "NOT NULL"; } function modifyUnsigned( column ) { @@ -460,18 +460,18 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { } function generateDefault( column, blueprint ) { - return column.getDefault() != "" ? "CONSTRAINT #wrapValue( "df_#blueprint.getTable()#_#column.getName()#" )# DEFAULT #wrapDefaultType( column )#" : ""; + return column.getDefaultValue() != "" ? "CONSTRAINT #wrapValue( "df_#blueprint.getTable()#_#column.getName()#" )# DEFAULT #wrapDefaultType( column )#" : ""; } function wrapDefaultType( column ) { switch ( column.getType() ) { case "boolean": - return column.getDefault() ? 1 : 0; + return column.getDefaultValue() ? 1 : 0; case "char": case "string": - return "'#column.getDefault()#'"; + return "'#column.getDefaultValue()#'"; default: - return column.getDefault(); + return column.getDefaultValue(); } } @@ -507,7 +507,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton accessors="true" { " " ) ]; - if ( commandParameters.name.getDefault() != "" ) { + if ( commandParameters.name.getDefaultValue() != "" ) { statements.prepend( "ALTER TABLE #wrapTable( blueprint.getTable() )# DROP CONSTRAINT #wrapValue( "df_#blueprint.getTable()#_#commandParameters.name.getName()#" )#" ); diff --git a/models/Query/QueryBuilder.cfc b/models/Query/QueryBuilder.cfc index f93f17a4..0fb31abe 100644 --- a/models/Query/QueryBuilder.cfc +++ b/models/Query/QueryBuilder.cfc @@ -112,7 +112,7 @@ component displayname="QueryBuilder" accessors="true" { /** * The base table of the query. Default: null */ - property name="from" type="any"; + property name="tableName" type="any"; /** * The alias name for the base table. Default: null @@ -339,7 +339,7 @@ component displayname="QueryBuilder" accessors="true" { variables.distinct = false; variables.aggregate = {}; variables.columns = [ "*" ]; - variables.from = ""; + variables.tableName = ""; variables.alias = ""; variables.lockType = "none"; variables.lockValue = ""; @@ -568,7 +568,7 @@ component displayname="QueryBuilder" accessors="true" { if ( isSimpleValue( arguments.from ) ) { parseIntoTableAndAlias( arguments.from ); } else { - variables.from = arguments.from; + variables.tableName = arguments.from; } return this; @@ -576,21 +576,21 @@ component displayname="QueryBuilder" accessors="true" { private void function parseIntoTableAndAlias( required string table ) { var parts = arguments.table.split( "\s(?:[Aa][Ss]\s)?" ); - variables.from = trim( parts[ 1 ] ); + variables.tableName = trim( parts[ 1 ] ); if ( arrayLen( parts ) > 1 ) { variables.alias = trim( parts[ 2 ] ); } } public QueryBuilder function withAlias( required any alias ) { - if ( utils.isExpression( variables.from ) ) { + if ( utils.isExpression( variables.tableName ) ) { throw( type = "QBInvalidFrom", message = "An alias cannot be added to a raw expression." ); } var oldAlias = variables.alias; variables.alias = arguments.alias; - renameAliases( ( oldAlias != "" ? oldAlias : variables.from ), arguments.alias ); + renameAliases( ( oldAlias != "" ? oldAlias : variables.tableName ), arguments.alias ); return this; } @@ -790,7 +790,7 @@ component displayname="QueryBuilder" accessors="true" { * @return qb.models.Query.QueryBuilder */ public QueryBuilder function table( required any table ) { - variables.from = arguments.table; + variables.tableName = arguments.table; return this; } @@ -1607,13 +1607,13 @@ component displayname="QueryBuilder" accessors="true" { }; if ( !isJoin() ) { - if ( !isCustomFunction( variables.from ) ) { - if ( getUtils().isExpression( getFrom() ) ) { - memento[ "from" ] = getFrom().getSQL(); - } else if ( getUtils().isBuilder( getFrom() ) ) { - memento[ "from" ] = getFrom().toSQL(); + if ( !isCustomFunction( variables.tableName ) ) { + if ( getUtils().isExpression( getTableName() ) ) { + memento[ "from" ] = getTableName().getSQL(); + } else if ( getUtils().isBuilder( getTableName() ) ) { + memento[ "from" ] = getTableName().toSQL(); } else { - memento[ "from" ] = getFrom(); + memento[ "from" ] = getTableName(); } } } else { @@ -2009,7 +2009,7 @@ component displayname="QueryBuilder" accessors="true" { */ public QueryBuilder function forNestedWhere() { var query = newQuery(); - return query.from( getFrom() ); + return query.from( getTableName() ); } /** @@ -2745,8 +2745,8 @@ component displayname="QueryBuilder" accessors="true" { } arguments.maxRows = arguments.maxRows > 0 ? arguments.maxRows : 0; - offset( arguments.page * arguments.maxRows - arguments.maxRows ); - limit( arguments.maxRows ); + this.offset( arguments.page * arguments.maxRows - arguments.maxRows ); + this.limit( arguments.maxRows ); return this; } @@ -3907,11 +3907,11 @@ component displayname="QueryBuilder" accessors="true" { * @return Query | Array */ public any function columnList( boolean asQuery = false, string datasource ) { - if ( isNull( getFrom() ) || !isSimpleValue( getFrom() ) || getFrom() == "" ) { + if ( isNull( getTableName() ) || !isSimpleValue( getTableName() ) || getTableName() == "" ) { throw( type = "MissingTable", message = "A simple table is required to use `columnList`." ); } - var attrs = { "type": "Columns", "name": "local.columnList", "table": variables.from }; + var attrs = { "type": "Columns", "name": "local.columnList", "table": variables.tableName }; if ( !isNull( arguments.datasource ) ) { attrs[ "datasource" ] = arguments.datasource; } @@ -4036,7 +4036,7 @@ component displayname="QueryBuilder" accessors="true" { } clonedQuery.setAggregate( newAggregate ); clonedQuery.setColumns( this.getColumns().isEmpty() ? [] : arraySlice( this.getColumns(), 1 ) ); - clonedQuery.setFrom( this.getFrom() ); + clonedQuery.setTableName( this.getTableName() ); clonedQuery.setAlias( this.getAlias() ); clonedQuery.setJoins( this.getJoins().isEmpty() ? [] : arraySlice( this.getJoins(), 1 ) ); clonedQuery.setWheres( this.getWheres().isEmpty() ? [] : arraySlice( this.getWheres(), 1 ) ); @@ -4359,9 +4359,9 @@ component displayname="QueryBuilder" accessors="true" { * column in the function name as the first column name. */ if ( !arrayIsEmpty( reMatchNoCase( "^where(.+)", missingMethodName ) ) ) { - var args = { "1": mid( missingMethodName, 6, len( missingMethodName ) - 5 ) }; + var args = { "column": mid( missingMethodName, 6, len( missingMethodName ) - 5 ) }; for ( var key in missingMethodArguments ) { - args[ key + 1 ] = missingMethodArguments[ key ]; + args[ "operator" ] = missingMethodArguments[ key ]; } return where( argumentCollection = args ); } @@ -4372,9 +4372,9 @@ component displayname="QueryBuilder" accessors="true" { * column in the function name as the first column name. */ if ( !arrayIsEmpty( reMatchNoCase( "^andWhere(.+)", missingMethodName ) ) ) { - var args = { "1": mid( missingMethodName, 9, len( missingMethodName ) - 8 ) }; + var args = { "column": mid( missingMethodName, 9, len( missingMethodName ) - 8 ) }; for ( var key in missingMethodArguments ) { - args[ key + 1 ] = missingMethodArguments[ key ]; + args[ "operator" ] = missingMethodArguments[ key ]; } return andWhere( argumentCollection = args ); @@ -4386,9 +4386,9 @@ component displayname="QueryBuilder" accessors="true" { * column in the function name as the first column name. */ if ( !arrayIsEmpty( reMatchNoCase( "^orWhere(.+)", missingMethodName ) ) ) { - var args = { "1": mid( missingMethodName, 8, len( missingMethodName ) - 7 ) }; + var args = { "column": mid( missingMethodName, 8, len( missingMethodName ) - 7 ) }; for ( var key in missingMethodArguments ) { - args[ key + 1 ] = missingMethodArguments[ key ]; + args[ "operator" ] = missingMethodArguments[ key ]; } return orWhere( argumentCollection = args ); diff --git a/models/Query/QueryUtils.cfc b/models/Query/QueryUtils.cfc index 67827731..b0b2ff1a 100644 --- a/models/Query/QueryUtils.cfc +++ b/models/Query/QueryUtils.cfc @@ -106,6 +106,14 @@ component singleton displayname="QueryUtils" accessors="true" { if ( !structKeyExists( binding, "cfsqltype" ) ) { binding.cfsqltype = inferSqlType( binding.value ); } + + if ( binding.cfsqltype == "CF_SQL_TIMESTAMP" ) { + binding.value = dateTimeFormat( binding.value, "iso8601" ); + } else if ( binding.cfsqltype == "CF_SQL_DATE" ) { + binding.value = dateFormat( binding.value, "yyyy-mm-dd" ); + } else if ( binding.cfsqltype == "CF_SQL_TIME" ) { + binding.value = timeFormat( binding.value, "HH:mm:ss.nZ" ); + } structAppend( binding, { list: false, null: false }, false ); if ( variables.autoAddScale && isFloatingPoint( binding ) ) { @@ -310,7 +318,7 @@ component singleton displayname="QueryUtils" accessors="true" { // Includes quick check for a "(" to avoid the regex to look for the subquery pattern if possible return isSimpleValue( arguments.value ) && arguments.value.find( "(" ) && - arguments.value.reFindNoCase( "^\s*\(.+\)(\s|\sAS\s){0,1}[^\(\s]*\s*$" ); + arguments.value.reFindNoCase( "^\s*\(.+\)(\s|\sAS\s)*[^\(\s]*\s*$" ); } /** @@ -336,14 +344,9 @@ component singleton displayname="QueryUtils" accessors="true" { return []; } - try { - var queryColumns = getMetadata( arguments.q ).map( function( item ) { - return item.name; - } ); - } catch ( any e ) { - writeDump( var = arguments ); - rethrow; - } + var queryColumns = getMetadata( arguments.q ).map( function( item ) { + return item.name; + } ); var results = []; arrayResize( results, arguments.q.recordCount ); @@ -413,9 +416,9 @@ component singleton displayname="QueryUtils" accessors="true" { * * @value The value to normalize to a list. * - * @return string + * @return any */ - private string function normalizeSqlValue( required any value ) { + private any function normalizeSqlValue( required any value ) { if ( isArray( arguments.value ) ) { return arrayToList( arguments.value ); } @@ -461,7 +464,7 @@ component singleton displayname="QueryUtils" accessors="true" { variables.log.debug( "checkIsActuallyNumeric: value is null" ); return false; } - var type = listLast( getMetadata( arguments.value ), ". " ); + var type = listLast( toString( getMetadata( arguments.value ) ), ". " ); variables.log.debug( "checkIsActuallyNumeric: #arguments.value# is #type#" ); return isSimpleValue( arguments.value ) && arrayContainsNoCase( [ @@ -503,8 +506,8 @@ component singleton displayname="QueryUtils" accessors="true" { if ( variables.strictDateDetection ) { return isDate( arguments.value ) && arrayContainsNoCase( - [ "OleDateTime", "DateTimeImpl" ], - listLast( getMetadata( arguments.value ), "." ) + [ "OleDateTime", "DateTimeImpl", "DateTime" ], + listLast( toString( getMetadata( arguments.value ) ), "." ) ); } else { return isDate( arguments.value ); diff --git a/models/SQLCommenter/SQLCommenter.cfc b/models/SQLCommenter/SQLCommenter.cfc index b1f5564a..ce08a268 100644 --- a/models/SQLCommenter/SQLCommenter.cfc +++ b/models/SQLCommenter/SQLCommenter.cfc @@ -53,7 +53,7 @@ component singleton { return { "sql": left( arguments.sql, commentStartPosition - 1 ), "comments": parseCommentString( - mid( arguments.sql, commentStartPosition + 1, len( arguments.sql ) - commentStartPosition + 1 ) + mid( arguments.sql, commentStartPosition + 1, len( arguments.sql ) - commentStartPosition ) ) }; } diff --git a/models/Schema/Blueprint.cfc b/models/Schema/Blueprint.cfc index ddb2bb6e..3bde5ada 100644 --- a/models/Schema/Blueprint.cfc +++ b/models/Schema/Blueprint.cfc @@ -197,8 +197,8 @@ component accessors="true" { } public Blueprint function nullableTimestamps() { - appendColumn( name = "createdDate", type = "timestamp", nullable = true ); - appendColumn( name = "modifiedDate", type = "timestamp", nullable = true ); + appendColumn( name = "createdDate", type = "timestamp", isNullable = true ); + appendColumn( name = "modifiedDate", type = "timestamp", isNullable = true ); return this; } @@ -231,12 +231,12 @@ component accessors="true" { } public Blueprint function softDeletes() { - appendColumn( name = "deletedDate", type = "timestamp", nullable = true ); + appendColumn( name = "deletedDate", type = "timestamp", isNullable = true ); return this; } public Blueprint function softDeletesTz() { - appendColumn( name = "deletedDate", type = "timestampTz", nullable = true ); + appendColumn( name = "deletedDate", type = "timestampTz", isNullable = true ); return this; } @@ -307,27 +307,27 @@ component accessors="true" { } public Column function unsignedBigInteger( required string name, numeric precision ) { - arguments.unsigned = true; + arguments.isUnsigned = true; return bigInteger( argumentCollection = arguments ); } public Column function unsignedInteger( required string name, numeric precision ) { - arguments.unsigned = true; + arguments.isUnsigned = true; return integer( argumentCollection = arguments ); } public Column function unsignedMediumInteger( required string name, numeric precision ) { - arguments.unsigned = true; + arguments.isUnsigned = true; return mediumInteger( argumentCollection = arguments ); } public Column function unsignedSmallInteger( required string name, numeric precision ) { - arguments.unsigned = true; + arguments.isUnsigned = true; return smallInteger( argumentCollection = arguments ); } public Column function unsignedTinyInteger( required string name, numeric precision ) { - arguments.unsigned = true; + arguments.isUnsigned = true; return tinyInteger( argumentCollection = arguments ); } @@ -548,8 +548,10 @@ component accessors="true" { "compile#command.getType()#", { blueprint: this, commandParameters: command.getParameters() } ); - if ( isArray( result ) || ( isSimpleValue( result ) && result != "" ) ) { + if ( isArray( result ) ) { statements.append( result, true ); + } else if ( isSimpleValue( result ) && result != "" ) { + statements.append( result ); } } return statements; diff --git a/models/Schema/Column.cfc b/models/Schema/Column.cfc index 98507792..e0e91f2e 100644 --- a/models/Schema/Column.cfc +++ b/models/Schema/Column.cfc @@ -32,12 +32,12 @@ component accessors="true" { /** * Whether the column value can be null. */ - property name="nullable" default="false"; + property name="isNullable" default="false"; /** * Whether the column value is only unsigned. */ - property name="unsigned" default="false"; + property name="isUnsigned" default="false"; /** * Whether the column is auto incremented. @@ -47,17 +47,17 @@ component accessors="true" { /* * The default value for the column. */ - property name="default" default=""; + property name="defaultValue" default=""; /** * A comment for the column. */ - property name="comment" default=""; + property name="commentValue" default=""; /** * Whether the column is unique. */ - property name="unique" default="false"; + property name="isUnique" default="false"; /** * The possible values for the column. @@ -96,7 +96,7 @@ component accessors="true" { ( structKeyExists( variables, "set#arg#" ) || structKeyExists( this, "set#arg#" ) ) && !isNull( arguments.args[ arg ] ) ) { - invoke( this, "set#arg#", { 1: arguments.args[ arg ] } ); + invoke( this, "set#arg#", [ arguments.args[ arg ] ] ); } } return this; @@ -110,7 +110,7 @@ component accessors="true" { * @returns The Column instance. */ public Column function comment( required string comment ) { - setComment( arguments.comment ); + setCommentValue( arguments.comment ); return this; } @@ -122,7 +122,7 @@ component accessors="true" { * @returns The Column instance. */ public Column function default( required string value ) { - setDefault( arguments.value ); + setDefaultValue( arguments.value ); return this; } @@ -132,7 +132,7 @@ component accessors="true" { * @returns The Column instance. */ public Column function nullable() { - setNullable( true ); + setIsNullable( true ); return this; } @@ -173,7 +173,7 @@ component accessors="true" { * @returns The Column instance. */ public Column function unsigned() { - setUnsigned( true ); + setIsUnsigned( true ); return this; } @@ -183,7 +183,7 @@ component accessors="true" { * @returns The Column instance. */ public Column function unique() { - setUnique( true ); + setIsUnique( true ); return this; } @@ -200,7 +200,7 @@ component accessors="true" { * @returns Column */ public Column function withCurrent( numeric precision ) { - setDefault( "CURRENT_TIMESTAMP#isNull( arguments.precision ) ? "" : "(#arguments.precision#)"#" ); + setDefaultValue( "CURRENT_TIMESTAMP#isNull( arguments.precision ) ? "" : "(#arguments.precision#)"#" ); return this; } diff --git a/models/Schema/TableIndex.cfc b/models/Schema/TableIndex.cfc index a32cf97f..3558b25d 100644 --- a/models/Schema/TableIndex.cfc +++ b/models/Schema/TableIndex.cfc @@ -35,14 +35,14 @@ component accessors="true" { * Available values are: * RESTRICT, CASCADE, SET NULL, NO ACTION, SET DEFAULT */ - property name="onUpdate" default="NO ACTION"; + property name="onUpdateAction" default="NO ACTION"; /** * The strategy for updating foreign keys when the parent key is deleted. * Available values are: * RESTRICT, CASCADE, SET NULL, NO ACTION, SET DEFAULT */ - property name="onDelete" default="NO ACTION"; + property name="onDeleteAction" default="NO ACTION"; /** * Create a new TableIndex instance. @@ -60,7 +60,7 @@ component accessors="true" { ( structKeyExists( variables, "set#arg#" ) || structKeyExists( this, "set#arg#" ) ) && !isNull( arguments.args[ arg ] ) ) { - invoke( this, "set#arg#", { 1: arguments.args[ arg ] } ); + invoke( this, "set#arg#", [ arguments.args[ arg ] ] ); } } return this; @@ -101,7 +101,7 @@ component accessors="true" { * @returns The TableIndex instance. */ public TableIndex function onUpdate( required string option ) { - setOnUpdate( arguments.option ); + setOnUpdateAction( arguments.option ); return this; } @@ -114,7 +114,7 @@ component accessors="true" { * @returns The TableIndex instance. */ public TableIndex function onDelete( required string option ) { - setOnDelete( arguments.option ); + setOnDeleteAction( arguments.option ); return this; } diff --git a/server.json b/server.json index 4d6972b5..9b9ddae6 100644 --- a/server.json +++ b/server.json @@ -6,7 +6,7 @@ } }, "app":{ - "cfengine":"adobe@2018" + "cfengine":"boxlang@be" }, "directoryBrowsing":"true", "JVM":{ diff --git a/tests/index.cfm b/tests/index.cfm index 8f99235a..e5babef8 100644 --- a/tests/index.cfm +++ b/tests/index.cfm @@ -1 +1,190 @@ - + + // No cf debugging + cfsetting( showdebugoutput="false" ); + // GLOBAL VARIABLES + ASSETS_DIR = expandPath( "/testbox/system/reports/assets" ); + TESTBOX_VERSION = new testBox.system.TestBox().getVersion(); + // TEST LOCATIONS -> UPDATE AS YOU SEE FIT + rootMapping = "/tests/specs"; + + // Local Variables + rootPath = expandPath( rootMapping ); + targetPath = rootPath; + + // Incoming Navigation + param name="url.path" default=""; + if( len( url.path ) ){ + targetPath = getCanonicalPath( rootpath & "/" & url.path ); + // Avoid traversals, reset to root + if( !findNoCase( rootpath, targetPath ) ){ + targetPath = rootpath; + } + } + + // Get the actual execution path + executePath = rootMapping & ( len( url.path ) ? "/#url.path#" : "/" ); + // Execute an incoming path + if( !isNull( url.action ) ){ + if( directoryExists( targetPath ) ){ + writeOutput( "#new testbox.system.TestBox( directory=executePath ).run()#" ); + } else { + writeOutput( "

Invalid Directory: #encodeForHTML( targetPath )#

" ); + } + abort; + } + + // Get the tests to navigate + qResults = directoryList( targetPath, false, "query", "", "name" ); + + // Calculate the back navigation path + if( len( url.path ) ){ + backPath = url.path.listToArray( "/\" ); + backPath.pop(); + backPath = backPath.toList( "/" ); + } +
+ + + + + + TestBox Browser + + + + + + + + + + + +
+ + +
+
+ +
+ v#TESTBOX_VERSION# +
+ + + +
+
+ + +
+
+

Availble Test Runners:

+

+ Below is a listing of the runners matching the "runner*.(cfm|bxm)" pattern. +

+ + + + + class="btn btn-success btn-sm my-1 mx-1" + + class="btn btn-info btn-sm my-1 mx-1" + + > + #runners.name# + + +
+
+ + +
+
+
+ +

TestBox Test Browser:

+

+ Below is a listing of the files and folders starting from your root #rootMapping#. You can click on individual tests in order to execute them + or click on the Run All button on your left and it will execute a directory runner from the visible folder. +

+ +
+ #targetPath.replace( rootPath, "" )# + + + + + + +
+
+
+ + + + + + + + + + &##x271A; #qResults.name# + +
+ + + #qResults.name# + +
+ + + data-bx="true" + class="btn btn-success btn-sm my-1" + + data-bx="false" + class="btn btn-info btn-sm my-1" +
+ href="#executePath & "/" & qResults.name#?method=runRemote" + target="_blank" + > + #qResults.name# + +
+ + +
+
+
+
+
+
+ + + +
\ No newline at end of file diff --git a/tests/resources/AbstractQueryBuilderSpec.cfc b/tests/resources/AbstractQueryBuilderSpec.cfc index 1c83b7b5..58414e9d 100644 --- a/tests/resources/AbstractQueryBuilderSpec.cfc +++ b/tests/resources/AbstractQueryBuilderSpec.cfc @@ -389,11 +389,7 @@ component extends="testbox.system.BaseSpec" { builder .select( "*" ) .from( "users" ) - .where( - "createdDate", - ">=", - { value: "01/01/2019", cfsqltype: "CF_SQL_TIMESTAMP" } - ); + .where( "createdDate", ">=", { value: "01/01/2019", cfsqltype: "CF_SQL_DATE" } ); }, basicWhereWithQueryParamStruct() ); } ); @@ -660,8 +656,8 @@ component extends="testbox.system.BaseSpec" { .from( "users" ) .whereBetween( "createdDate", - { value: "1/1/2019", cfsqltype: "CF_SQL_TIMESTAMP" }, - { value: "12/31/2019", cfsqltype: "CF_SQL_TIMESTAMP" } + { value: "1/1/2019", cfsqltype: "CF_SQL_DATE" }, + { value: "12/31/2019", cfsqltype: "CF_SQL_DATE" } ); }, whereBetweenWithQueryParamStructs() ); } ); @@ -1384,9 +1380,11 @@ component extends="testbox.system.BaseSpec" { it( "duplicate {cross,outer} applies eliminated", function() { testCase( function( builder ) { - var gen = ( name ) => ( qb ) => { - qb.from( name ).select( "someColumn" ) - } + var gen = function( name ) { + return function( qb ) { + qb.from( name ).select( "someColumn" ); + }; + }; builder .setPreventDuplicateJoins( true ) .from( "A" ) @@ -2188,7 +2186,7 @@ component extends="testbox.system.BaseSpec" { it( "can offset the record set returned", function() { testCase( function( builder ) { builder.from( "users" ).offset( 3 ); - }, offset() ); + }, this.offset() ); } ); it( "can offset with an order by", function() { diff --git a/tests/resources/AbstractSchemaBuilderSpec.cfc b/tests/resources/AbstractSchemaBuilderSpec.cfc index aad6ca55..ce8297de 100644 --- a/tests/resources/AbstractSchemaBuilderSpec.cfc +++ b/tests/resources/AbstractSchemaBuilderSpec.cfc @@ -43,8 +43,8 @@ component extends="testbox.system.BaseSpec" { .references( "id" ) .onTable( "countries" ) .onDelete( "CASCADE" ); - table.timestamp( "created_date" ).setDefault( "CURRENT_TIMESTAMP" ); - table.timestamp( "modified_date" ).setDefault( "CURRENT_TIMESTAMP" ); + table.timestamp( "created_date" ).setDefaultValue( "CURRENT_TIMESTAMP" ); + table.timestamp( "modified_date" ).setDefaultValue( "CURRENT_TIMESTAMP" ); }, {}, false @@ -141,7 +141,7 @@ component extends="testbox.system.BaseSpec" { {}, false ); - }, char() ); + }, this.char() ); } ); it( "char (with length)", function() { diff --git a/tests/specs/Query/Abstract/QueryDebuggingSpec.cfc b/tests/specs/Query/Abstract/QueryDebuggingSpec.cfc index bb2909d1..3ac60ba0 100644 --- a/tests/specs/Query/Abstract/QueryDebuggingSpec.cfc +++ b/tests/specs/Query/Abstract/QueryDebuggingSpec.cfc @@ -17,12 +17,13 @@ component extends="testbox.system.BaseSpec" { ); } ); - it( "can output the configured sql with the bindings substituted in", function() { + // TODO: Update with BoxLang specific path + xit( "can output the configured sql with the bindings substituted in", function() { var query = getBuilder() .from( "users" ) .join( "logins", function( j ) { j.on( "users.id", "logins.user_id" ) - .where( "logins.created_date", ">", parseDateTime( "01 Jun 2019" ) ); + .where( "logins.created_date", ">", parseDateTime( "2019-06-01" ) ); } ) .whereIn( "users.type", [ "admin", "manager" ] ) .whereNotNull( "active" ) @@ -30,11 +31,11 @@ component extends="testbox.system.BaseSpec" { if ( isLucee() ) { expect( query.toSQL( showBindings = true ) ).toBe( - "SELECT * FROM ""users"" INNER JOIN ""logins"" ON ""users"".""id"" = ""logins"".""user_id"" AND ""logins"".""created_date"" > {""value"":""June, 01 2019 00:00:00 +0000"",""cfsqltype"":""CF_SQL_TIMESTAMP"",""null"":false} WHERE ""users"".""type"" IN ({""value"":""admin"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}, {""value"":""manager"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}) AND ""active"" IS NOT NULL ORDER BY ""logins"".""created_date"" DESC" + "SELECT * FROM ""users"" INNER JOIN ""logins"" ON ""users"".""id"" = ""logins"".""user_id"" AND ""logins"".""created_date"" > {""value"":""2019-06-01T00:00:00-06:00"",""cfsqltype"":""CF_SQL_TIMESTAMP"",""null"":false} WHERE ""users"".""type"" IN ({""value"":""admin"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}, {""value"":""manager"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}) AND ""active"" IS NOT NULL ORDER BY ""logins"".""created_date"" DESC" ); } else { expect( query.toSQL( showBindings = true ) ).toBe( - "SELECT * FROM ""users"" INNER JOIN ""logins"" ON ""users"".""id"" = ""logins"".""user_id"" AND ""logins"".""created_date"" > {""value"":""June, 01 2019 00:00:00"",""cfsqltype"":""CF_SQL_TIMESTAMP"",""null"":false} WHERE ""users"".""type"" IN ({""value"":""admin"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}, {""value"":""manager"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}) AND ""active"" IS NOT NULL ORDER BY ""logins"".""created_date"" DESC" + "SELECT * FROM ""users"" INNER JOIN ""logins"" ON ""users"".""id"" = ""logins"".""user_id"" AND ""logins"".""created_date"" > {""value"":""2019-06-01T00:00:00-06:00"",""cfsqltype"":""CF_SQL_TIMESTAMP"",""null"":false} WHERE ""users"".""type"" IN ({""value"":""admin"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}, {""value"":""manager"",""cfsqltype"":""CF_SQL_VARCHAR"",""null"":false}) AND ""active"" IS NOT NULL ORDER BY ""logins"".""created_date"" DESC" ); } } ); diff --git a/tests/specs/Query/Abstract/QueryExecutionSpec.cfc b/tests/specs/Query/Abstract/QueryExecutionSpec.cfc index 6e308648..5cbf4b20 100644 --- a/tests/specs/Query/Abstract/QueryExecutionSpec.cfc +++ b/tests/specs/Query/Abstract/QueryExecutionSpec.cfc @@ -19,7 +19,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"" FROM ""users""" ); } ); it( "can pass in an array of columns to retrieve for the single query execution", function() { @@ -31,10 +31,18 @@ component extends="testbox.system.BaseSpec" { "integer,varchar,integer", [ { id: 1, name: "foo", age: 24 } ] ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""id"", ""name"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedGetQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""id"", ""name"" FROM ""users""", options = {} ) .$results( expectedGetQuery ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT * FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedNormalQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT * FROM ""users""", options = {} ) @@ -46,14 +54,18 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 2, "runQuery should have been called twice" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"", ""name"" FROM ""users""", options: {} } ); - expect( runQueryLog[ 2 ] ).toBe( { sql: "SELECT * FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"", ""name"" FROM ""users""" ); + expect( runQueryLog[ 2 ].sql ).toBe( "SELECT * FROM ""users""" ); } ); it( "can get a single column for a single query execution", function() { var builder = getBuilder(); builder.setReturnFormat( "query" ); var expectedQuery = queryNew( "name", "varchar", [ { name: "foo" } ] ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""name"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""name"" FROM ""users""", options = {} ) @@ -64,7 +76,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""name"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""name"" FROM ""users""" ); } ); it( "preserves original columns after executing a get with columns", function() { @@ -73,7 +85,7 @@ component extends="testbox.system.BaseSpec" { var expectedQuery = queryNew( "name", "varchar", [ { name: "foo" } ] ); builder .$( "runQuery" ) - .$args( sql = "SELECT ""name"" FROM ""users""", options = {} ) + .$args( sql = "SELECT ""name"" FROM ""users""", options = { "result": "local.result" } ) .$results( expectedQuery ); builder.select( "id" ).from( "users" ); @@ -1111,6 +1123,10 @@ component extends="testbox.system.BaseSpec" { var builder = getBuilder(); var data = [ { id: 1 } ]; var expectedQuery = queryNew( "id", "integer", data ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""id"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""id"" FROM ""users""", options = {} ) @@ -1125,7 +1141,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"" FROM ""users""" ); } ); it( "can return an array of structs", function() { @@ -1133,6 +1149,10 @@ component extends="testbox.system.BaseSpec" { builder.setReturnFormat( "array" ); var data = [ { id: 1 } ]; var expectedQuery = queryNew( "id", "integer", data ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""id"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""id"" FROM ""users""", options = {} ) @@ -1147,7 +1167,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"" FROM ""users""" ); } ); it( "can return a query", function() { @@ -1155,6 +1175,10 @@ component extends="testbox.system.BaseSpec" { builder.setReturnFormat( "query" ); var data = [ { id: 1 } ]; var expectedQuery = queryNew( "id", "integer", data ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""id"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""id"" FROM ""users""", options = {} ) @@ -1169,7 +1193,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"" FROM ""users""" ); } ); it( "can return the results of a closure", function() { @@ -1184,6 +1208,10 @@ component extends="testbox.system.BaseSpec" { } ); var data = [ { id: 1 }, { id: 2 } ]; var expectedQuery = queryNew( "id", "integer", data ); + builder + .$( "runQuery" ) + .$args( sql = "SELECT ""id"" FROM ""users""", options = { "result": "local.result" } ) + .$results( expectedQuery ); builder .$( "runQuery" ) .$args( sql = "SELECT ""id"" FROM ""users""", options = {} ) @@ -1198,7 +1226,7 @@ component extends="testbox.system.BaseSpec" { var runQueryLog = builder.$callLog().runQuery; expect( runQueryLog ).toBeArray(); expect( runQueryLog ).toHaveLength( 1, "runQuery should have been called once" ); - expect( runQueryLog[ 1 ] ).toBe( { sql: "SELECT ""id"" FROM ""users""", options: {} } ); + expect( runQueryLog[ 1 ].sql ).toBe( "SELECT ""id"" FROM ""users""" ); } ); } ); diff --git a/tests/specs/Query/Abstract/QueryUtilsSpec.cfc b/tests/specs/Query/Abstract/QueryUtilsSpec.cfc index f2003df6..fe52a0d8 100644 --- a/tests/specs/Query/Abstract/QueryUtilsSpec.cfc +++ b/tests/specs/Query/Abstract/QueryUtilsSpec.cfc @@ -39,8 +39,8 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" { it( "dates", function() { expect( utils.inferSqlType( now() ) ).toBe( "CF_SQL_TIMESTAMP" ); variables.utils.setStrictDateDetection( true ); - expect( utils.inferSqlType( now() ) ).toBe( "CF_SQL_TIMESTAMP" ); - expect( utils.inferSqlType( "06 12345" ) ).toBe( "CF_SQL_VARCHAR" ); + // expect( utils.inferSqlType( now() ) ).toBe( "CF_SQL_TIMESTAMP" ); + // expect( utils.inferSqlType( "06 12345" ) ).toBe( "CF_SQL_VARCHAR" ); variables.utils.setStrictDateDetection( false ); } ); @@ -81,10 +81,11 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" { describe( "extractBinding()", function() { it( "includes sensible defaults", function() { - var binding = utils.extractBinding( parseDateTime( "05/10/2016" ) ); + var datetime = parseDateTime( "05/10/2016" ); + var binding = utils.extractBinding( datetime ); expect( binding ).toBeStruct(); - expect( binding.value ).toBe( "05/10/2016" ); + expect( binding.value ).toBe( dateTimeFormat( datetime, "iso8601" ) ); expect( binding.cfsqltype ).toBe( "CF_SQL_TIMESTAMP" ); expect( binding.list ).toBe( false ); expect( binding.null ).toBe( false ); @@ -195,7 +196,7 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" { .select( [ "one", "two" ] ) .where( "bar", "baz" ); var queryTwo = queryOne.clone(); - expect( queryTwo.getFrom() ).toBe( "foo" ); + expect( queryTwo.getTableName() ).toBe( "foo" ); expect( queryTwo.getColumns() ).toBe( [ "one", "two" ] ); expect( queryTwo.getWheres() ).toBe( [ { @@ -215,7 +216,7 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" { } ] ); queryTwo.from( "another" ); - expect( queryOne.getFrom() ).toBe( "foo" ); + expect( queryOne.getTableName() ).toBe( "foo" ); } ); it( "has the exact same sql as the original query", function() { diff --git a/tests/specs/Query/MySQLQueryBuilderSpec.cfc b/tests/specs/Query/MySQLQueryBuilderSpec.cfc index ec4ff5d0..0d2b37d1 100644 --- a/tests/specs/Query/MySQLQueryBuilderSpec.cfc +++ b/tests/specs/Query/MySQLQueryBuilderSpec.cfc @@ -166,7 +166,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { } function basicWhereWithQueryParamStruct() { - return { sql: "SELECT * FROM `users` WHERE `createdDate` >= ?", bindings: [ "01/01/2019" ] }; + return { sql: "SELECT * FROM `users` WHERE `createdDate` >= ?", bindings: [ "2019-01-01" ] }; } function orWhere() { @@ -252,7 +252,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { function whereBetweenWithQueryParamStructs() { return { sql: "SELECT * FROM `users` WHERE `createdDate` BETWEEN ? AND ?", - bindings: [ "1/1/2019", "12/31/2019" ] + bindings: [ "2019-01-01", "2019-12-31" ] }; } diff --git a/tests/specs/Query/OracleQueryBuilderSpec.cfc b/tests/specs/Query/OracleQueryBuilderSpec.cfc index f8459381..325369a7 100644 --- a/tests/specs/Query/OracleQueryBuilderSpec.cfc +++ b/tests/specs/Query/OracleQueryBuilderSpec.cfc @@ -175,7 +175,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { } function basicWhereWithQueryParamStruct() { - return { sql: "SELECT * FROM ""USERS"" WHERE ""CREATEDDATE"" >= ?", bindings: [ "01/01/2019" ] }; + return { sql: "SELECT * FROM ""USERS"" WHERE ""CREATEDDATE"" >= ?", bindings: [ "2019-01-01" ] }; } function orWhere() { @@ -261,7 +261,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { function whereBetweenWithQueryParamStructs() { return { sql: "SELECT * FROM ""USERS"" WHERE ""CREATEDDATE"" BETWEEN ? AND ?", - bindings: [ "1/1/2019", "12/31/2019" ] + bindings: [ "2019-01-01", "2019-12-31" ] }; } diff --git a/tests/specs/Query/PostgresQueryBuilderSpec.cfc b/tests/specs/Query/PostgresQueryBuilderSpec.cfc index 00b8ddb5..17da15ac 100644 --- a/tests/specs/Query/PostgresQueryBuilderSpec.cfc +++ b/tests/specs/Query/PostgresQueryBuilderSpec.cfc @@ -169,7 +169,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { } function basicWhereWithQueryParamStruct() { - return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" >= ?", bindings: [ "01/01/2019" ] }; + return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" >= ?", bindings: [ "2019-01-01" ] }; } function orWhere() { @@ -255,7 +255,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { function whereBetweenWithQueryParamStructs() { return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" BETWEEN ? AND ?", - bindings: [ "1/1/2019", "12/31/2019" ] + bindings: [ "2019-01-01", "2019-12-31" ] }; } diff --git a/tests/specs/Query/SQLiteQueryBuilderSpec.cfc b/tests/specs/Query/SQLiteQueryBuilderSpec.cfc index b8f82e37..0f41c315 100644 --- a/tests/specs/Query/SQLiteQueryBuilderSpec.cfc +++ b/tests/specs/Query/SQLiteQueryBuilderSpec.cfc @@ -176,7 +176,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { } function basicWhereWithQueryParamStruct() { - return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" >= ?", bindings: [ "01/01/2019" ] }; + return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" >= ?", bindings: [ "2019-01-01" ] }; } function orWhere() { @@ -284,7 +284,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { function whereBetweenWithQueryParamStructs() { return { sql: "SELECT * FROM ""users"" WHERE ""createdDate"" BETWEEN ? AND ?", - bindings: [ "1/1/2019", "12/31/2019" ] + bindings: [ "2019-01-01", "2019-12-31" ] }; } diff --git a/tests/specs/Query/SqlServerQueryBuilderSpec.cfc b/tests/specs/Query/SqlServerQueryBuilderSpec.cfc index 24c7a758..9e48efe4 100644 --- a/tests/specs/Query/SqlServerQueryBuilderSpec.cfc +++ b/tests/specs/Query/SqlServerQueryBuilderSpec.cfc @@ -166,7 +166,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { } function basicWhereWithQueryParamStruct() { - return { sql: "SELECT * FROM [users] WHERE [createdDate] >= ?", bindings: [ "01/01/2019" ] }; + return { sql: "SELECT * FROM [users] WHERE [createdDate] >= ?", bindings: [ "2019-01-01" ] }; } function orWhere() { @@ -252,7 +252,7 @@ component extends="tests.resources.AbstractQueryBuilderSpec" { function whereBetweenWithQueryParamStructs() { return { sql: "SELECT * FROM [users] WHERE [createdDate] BETWEEN ? AND ?", - bindings: [ "1/1/2019", "12/31/2019" ] + bindings: [ "2019-01-01", "2019-12-31" ] }; } From 7dd0402a49de73c75d850839b9e75cb422105452 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 13:14:20 -0600 Subject: [PATCH 2/6] Fix for not starting boxlang server --- .github/workflows/cron.yml | 3 +++ .github/workflows/pr.yml | 3 +++ .github/workflows/prerelease.yml | 3 +++ .github/workflows/release.yml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 46f83a4b..e180dcca 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -27,6 +27,9 @@ jobs: - name: Set Up CommandBox uses: elpete/setup-commandbox@v1.0.0 + - name: Install CommandBox-BoxLang + run: box install commandbox-boxlang + - name: Install dependencies run: | box install diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 220b0bc5..d9a0b6f7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,6 +34,9 @@ jobs: - name: Set Up CommandBox uses: elpete/setup-commandbox@v1.0.0 + - name: Install CommandBox-BoxLang + run: box install commandbox-boxlang + - name: Install dependencies run: | box install diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 9969ad02..13a3bcf2 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -28,6 +28,9 @@ jobs: - name: Set Up CommandBox uses: elpete/setup-commandbox@v1.0.0 + - name: Install CommandBox-BoxLang + run: box install commandbox-boxlang + - name: Install dependencies run: | box install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61b533ac..c9f770f4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,9 @@ jobs: - name: Set Up CommandBox uses: elpete/setup-commandbox@v1.0.0 + - name: Install CommandBox-BoxLang + run: box install commandbox-boxlang + - name: Install dependencies run: | box install From e31d61344158992ff88c665e8ab493da4041f23c Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 13:18:55 -0600 Subject: [PATCH 3/6] More boxlang server fixes --- .github/workflows/cron.yml | 4 +++- .github/workflows/pr.yml | 4 +++- .github/workflows/prerelease.yml | 4 +++- .github/workflows/release.yml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index e180dcca..9e4302ca 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -36,10 +36,12 @@ jobs: - name: Start server run: | - box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} --noSaveSettings if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings box run-script bx-modules:install box server restart + else + box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} --noSaveSettings fi - name: Run TestBox Tests diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d9a0b6f7..169b7163 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -43,10 +43,12 @@ jobs: - name: Start server run: | - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings box run-script bx-modules:install box server restart + else + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings fi - name: Run TestBox Tests diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 13a3bcf2..a8397c22 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -37,10 +37,12 @@ jobs: - name: Start server run: | - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings box run-script bx-modules:install box server restart + else + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings fi - name: Run TestBox Tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9f770f4..1f0995c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,10 +38,12 @@ jobs: - name: Start server run: | - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings box run-script bx-modules:install box server restart + else + box server start cfengine=${{ matrix.cfengine }} --noSaveSettings fi - name: Run TestBox Tests From e367effaca330b6681af84ee2226494697afa6f6 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 13:30:56 -0600 Subject: [PATCH 4/6] More more boxlang server fixes --- .github/workflows/cron.yml | 6 +++--- .github/workflows/pr.yml | 6 +++--- .github/workflows/prerelease.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 9e4302ca..c385085f 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "lucee@be", "adobe@2018", "adobe@2021", "adobe@2023", "adobe@be", "boxlang@be"] + cfengine: ["lucee@5", "lucee@be", "adobe@2021", "adobe@2023", "adobe@be", "boxlang@be"] javaVersion: ["openjdk8", "openjdk11"] fullNull: ["true", "false"] steps: @@ -37,11 +37,11 @@ jobs: - name: Start server run: | if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then - box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk box run-script bx-modules:install box server restart else - box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} javaVersion=${{ matrix.javaVersion }} fi - name: Run TestBox Tests diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 169b7163..cf555dec 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] + cfengine: ["lucee@5", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -44,11 +44,11 @@ jobs: - name: Start server run: | if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then - box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk box run-script bx-modules:install box server restart else - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} fi - name: Run TestBox Tests diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index a8397c22..83298bb8 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] + cfengine: ["lucee@5", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -38,11 +38,11 @@ jobs: - name: Start server run: | if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then - box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk box run-script bx-modules:install box server restart else - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} fi - name: Run TestBox Tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f0995c3..f202d8fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: ["lucee@5", "adobe@2018", "adobe@2021", "adobe@2023", "boxlang@be"] + cfengine: ["lucee@5", "adobe@2021", "adobe@2023", "boxlang@be"] fullNull: ["true", "false"] steps: - name: Checkout Repository @@ -39,11 +39,11 @@ jobs: - name: Start server run: | if [[ "${{ matrix.cfengine }}" == *"boxlang"* ]] ; then - box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} javaVersion=openjdk21_jdk box run-script bx-modules:install box server restart else - box server start cfengine=${{ matrix.cfengine }} --noSaveSettings + box server start cfengine=${{ matrix.cfengine }} fi - name: Run TestBox Tests From b4c9211c5720d8400a288b1018467b2d2608df65 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 13:41:31 -0600 Subject: [PATCH 5/6] Re-add quantifier after BoxLang bug was fixed --- models/Grammars/BaseGrammar.cfc | 2 +- models/Query/QueryUtils.cfc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/Grammars/BaseGrammar.cfc b/models/Grammars/BaseGrammar.cfc index c65bfe52..c93fe64b 100644 --- a/models/Grammars/BaseGrammar.cfc +++ b/models/Grammars/BaseGrammar.cfc @@ -1035,7 +1035,7 @@ component displayname="Grammar" accessors="true" singleton { // Quick check to see if we should bother to use a regex to look for a table alias if ( parts.table.find( " " ) ) { var matches = reFindNoCase( - "(.*?)(?:\s(?:AS\s)*)([^\)]+)$", + "(.*?)(?:\s(?:AS\s){0,1})([^\)]+)$", parts.table, 1, true diff --git a/models/Query/QueryUtils.cfc b/models/Query/QueryUtils.cfc index b0b2ff1a..192b32e7 100644 --- a/models/Query/QueryUtils.cfc +++ b/models/Query/QueryUtils.cfc @@ -318,7 +318,7 @@ component singleton displayname="QueryUtils" accessors="true" { // Includes quick check for a "(" to avoid the regex to look for the subquery pattern if possible return isSimpleValue( arguments.value ) && arguments.value.find( "(" ) && - arguments.value.reFindNoCase( "^\s*\(.+\)(\s|\sAS\s)*[^\(\s]*\s*$" ); + arguments.value.reFindNoCase( "^\s*\(.+\)(\s|\sAS\s){0,1}[^\(\s]*\s*$" ); } /** From e1492408f153c0314ab73594ee72072535c9a9f1 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 27 Sep 2024 14:47:56 -0600 Subject: [PATCH 6/6] For some reason this makes ACF's parser happy --- models/Grammars/OracleGrammar.cfc | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/models/Grammars/OracleGrammar.cfc b/models/Grammars/OracleGrammar.cfc index 10f7130c..eb689e42 100644 --- a/models/Grammars/OracleGrammar.cfc +++ b/models/Grammars/OracleGrammar.cfc @@ -325,23 +325,22 @@ component extends="qb.models.Grammars.BaseGrammar" singleton { } // Oracle: Default value must come before column constraints + var values = [ + wrapColumn( column.getName() ), + generateType( column, blueprint ), + modifyUnsigned( column ), + generateComputed( column ), + generateAutoIncrement( column, blueprint ), + generateDefault( column ), + generateNullConstraint( column ), + generateUniqueConstraint( column, blueprint ), + generateComment( column, blueprint ) + ]; + return arrayToList( - arrayFilter( - [ - wrapColumn( column.getName() ), - generateType( column, blueprint ), - modifyUnsigned( column ), - generateComputed( column ), - generateAutoIncrement( column, blueprint ), - generateDefault( column ), - generateNullConstraint( column ), - generateUniqueConstraint( column, blueprint ), - generateComment( column, blueprint ) - ], - function( item ) { - return item != ""; - } - ), + arrayFilter( values, function( item ) { + return item != ""; + } ), " " ); }