Skip to content

Commit

Permalink
Normalize line endings and trim whitespace at the end of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Aug 15, 2017
1 parent d0cc901 commit bf4ecc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions models/Query/Builder.cfc
Expand Up @@ -258,7 +258,7 @@ component displayname="Builder" accessors="true" {
args[ count ] = arguments[ arg ];
count--;
}

if ( variables.columns.isEmpty() ||
( variables.columns.len() == 1 && isSimpleValue( variables.columns[ 1 ] ) && variables.columns[ 1 ] == "*" ) ) {
variables.columns = [];
Expand Down Expand Up @@ -288,7 +288,7 @@ component displayname="Builder" accessors="true" {
if ( ! arrayIsEmpty( arguments.bindings ) ) {
addBindings( arguments.bindings, "select" );
}
return this;
return this;
}

/********************************************************************************\
Expand Down Expand Up @@ -1067,7 +1067,7 @@ component displayname="Builder" accessors="true" {
/**
* Add a group by clause to the query.
* `groupBy` allows three ways to specify the grouping columns:
* - a comma-separated list
* - a comma-separated list
* - an array
* - variadic arguments
* All the columns passed this way will be individually added to the query.
Expand Down Expand Up @@ -1143,7 +1143,7 @@ component displayname="Builder" accessors="true" {
* Add an order by clause to the query. To order by multiple columns, call `orderBy` multiple times.
* The order in which `orderBy` is called matters and is the order it appears in the SQL.
*
* @column The name of the column(s) to order by. An expression (`builder.raw()`) can be passed as well. An array can be passed with any combination of simple values, array, struct, or list for each entry in the array (an example with all possible value styles: column = [ "last_name", [ "age", "desc" ], { column = "favorite_color", direction = "desc" }, "height|desc" ];. The column argument can also just accept a comman delimited list with a pipe ( | ) as the secondary delimiter denoting the direction of the order by. The pipe delimiter is also used when parsing the column argument when it is passed as an array and the entry in the array is a pipe delimited string.
* @column The name of the column(s) to order by. An expression (`builder.raw()`) can be passed as well. An array can be passed with any combination of simple values, array, struct, or list for each entry in the array (an example with all possible value styles: column = [ "last_name", [ "age", "desc" ], { column = "favorite_color", direction = "desc" }, "height|desc" ];. The column argument can also just accept a comman delimited list with a pipe ( | ) as the secondary delimiter denoting the direction of the order by. The pipe delimiter is also used when parsing the column argument when it is passed as an array and the entry in the array is a pipe delimited string.
* @direction The direction by which to order the query. Accepts "asc" OR "desc". Default: "asc". If column argument is an array this argument will be used as the default value for all entries in the column list or array that fail to specify a direction for a speicifc column.
*
* @return qb.models.Query.Builder
Expand All @@ -1156,7 +1156,7 @@ component displayname="Builder" accessors="true" {
column = column
} );
}
// if the column argument is an array
// if the column argument is an array
else if ( isArray( column ) ) {

for ( var col in column ) {
Expand Down Expand Up @@ -1205,7 +1205,7 @@ component displayname="Builder" accessors="true" {
column = col[1]
});
}

}

}
Expand All @@ -1216,7 +1216,7 @@ component displayname="Builder" accessors="true" {

for ( var col in arCols ) {
var colName = listFirst( col, "|" );

if ( listLen( col, "|" ) == 2 ) {
var dir = ( arrayFindNoCase( variables.directions, listLast( col, "|" ) ) ) ? listLast( col, "|" ) : direction;
} else {
Expand Down Expand Up @@ -1300,7 +1300,7 @@ component displayname="Builder" accessors="true" {
/**
* When is a useful helper method that introduces if / else control flow without breaking chainability.
* When the `condition` is true, the `onTrue` callback is triggered. If the `condition` is false and an `onFalse` callback is passed, it is triggered. Otherwise, the query is returned unmodified.
*
*
* @condition A boolean condition that if true will trigger the `onTrue` callback. If not true, the `onFalse` callback will trigger if it was passed. Otherwise, the query is returned unmodified.
* @onTrue A closure that will be triggered if the `condition` is true.
* @onFlase A closure that will be triggered if the `condition` is false.
Expand Down Expand Up @@ -1437,10 +1437,10 @@ component displayname="Builder" accessors="true" {
public any function updateOrInsert(
required struct values,
struct options = {},
boolean toSql = false
boolean toSql = false
) {
if ( exists() ) {
return this.limit( 1 ).update( argumentCollection = arguments );
return this.limit( 1 ).update( argumentCollection = arguments );
}

return this.insert( argumentCollection = arguments );
Expand Down Expand Up @@ -1473,7 +1473,7 @@ component displayname="Builder" accessors="true" {
if ( toSql ) {
return sql;
}

return runQuery( sql, options, "result" );
}

Expand Down Expand Up @@ -1631,7 +1631,7 @@ component displayname="Builder" accessors="true" {
/**
* Returns true if the query returns any rows.
*
* @options Any options to pass to `queryExecute`. Default: {}.
* @options Any options to pass to `queryExecute`. Default: {}.
*
* @return boolean
*/
Expand Down Expand Up @@ -1830,7 +1830,7 @@ component displayname="Builder" accessors="true" {
* Sets the return format for the query.
* The return format can be a simple string like "query" to return queries or "array" to return an array of structs.
* Alternative, the return format can be a closure. The closure is passed the query as the only argument. The result of the closure is returned as the result of the query.
*
*
* @format "query", "array", or a closure.
*
* @return qb.models.Query.Builder
Expand Down
24 changes: 12 additions & 12 deletions tests/specs/Query/Builder+GrammarSpec.cfc
Expand Up @@ -696,7 +696,7 @@ component extends="testbox.system.BaseSpec" {
"SELECT * FROM ""users"" GROUP BY ""id"", ""email"""
);
}

expect( getTestBindings( builder ) ).toBe( [] );
} );

Expand Down Expand Up @@ -853,8 +853,8 @@ component extends="testbox.system.BaseSpec" {
var builder = getBuilder();
builder.select( "*").from( "users" )
.orderBy( [
[ "last_name", "desc" ],
[ "age", "forward" ],
[ "last_name", "desc" ],
[ "age", "forward" ],
"favorite_color|backward",
"favorite_food|desc",
{ column = "height", direction = "tallest" },
Expand All @@ -871,7 +871,7 @@ component extends="testbox.system.BaseSpec" {
it( "as raw expressions", function(){
var builder = getBuilder();
builder.select( "*").from( "users" )
.orderBy( [
.orderBy( [
builder.raw( "DATE(created_at)" ),
{ column = builder.raw( "DATE(modified_at)" ) }
] );
Expand All @@ -894,10 +894,10 @@ component extends="testbox.system.BaseSpec" {
it( "can accept a struct with a column key and optionally the direction key", function(){
var builder = getBuilder();
builder.select( "*").from( "users" )
.orderBy( [
.orderBy( [
{ column = "last_name" },
{ column = "age", direction = "asc" },
{ column = "favorite_color", direction = "desc" }
{ column = "favorite_color", direction = "desc" }
], "desc" );

expect( builder.toSql() ).toBeWithCase(
Expand Down Expand Up @@ -946,7 +946,7 @@ component extends="testbox.system.BaseSpec" {
});

});

});

describe( "can accept a comma delimited list for the column argument", function(){
Expand Down Expand Up @@ -994,9 +994,9 @@ component extends="testbox.system.BaseSpec" {
});

});

});

} );

describe( "limits", function() {
Expand Down Expand Up @@ -1591,9 +1591,9 @@ component extends="testbox.system.BaseSpec" {
builder.from( "users" ).count();

expect( builder.getAggregate() ).toBeEmpty( "Aggregate should have been cleared after running" );
} );
} );
} );

describe( "max", function() {
it( "can return the max record of a table", function() {
var builder = getBuilder();
Expand All @@ -1617,7 +1617,7 @@ component extends="testbox.system.BaseSpec" {
} );

expect( builder.getAggregate() ).toBeEmpty( "Aggregate should have been cleared after running" );
} );
} );
} );

describe( "min", function() {
Expand Down

0 comments on commit bf4ecc7

Please sign in to comment.