Skip to content
Permalink
Browse files
fix(QueryBuilder): Add a type to the onMissingMethod exception
Adding a type allows other libraries to better detect and provide
more context for missing methods.
  • Loading branch information
elpete committed Jan 25, 2020
1 parent 119e434 commit 90d109312b2ea86c00db34020b12b5ab22bb377b
Showing 6 changed files with 46 additions and 14 deletions.
@@ -52,7 +52,7 @@ component displayname="Grammar" accessors="true" singleton {
*
* @return qb.models.Grammars.BaseGrammar
*/
public BaseGrammar function init( qb.models.Query.QueryUtils utils = new qb.models.Query.QueryUtils( ) {
public BaseGrammar function init( qb.models.Query.QueryUtils utils = new qb.models.Query.QueryUtils() ) {
variables.utils = arguments.utils;
variables.tablePrefix = "";
// These are overwritten by WireBox, if it exists.
@@ -2625,7 +2625,7 @@ component displayname="QueryBuilder" accessors="true" {
return invoke( variables.parentQuery.populateQuery( this ), missingMethodName, missingMethodArguments );
}

throw( "Method does not exist on QueryBuilder [#missingMethodName#]" );
throw( type = "QBMissingMethod", message = "Method does not exist on QueryBuilder [#missingMethodName#]" );
}

/**
@@ -0,0 +1,9 @@
component {

function test() {
describe( "someting", function() {
query;
} );
}

}
@@ -38,7 +38,11 @@ component extends="testbox.system.BaseSpec" {
table.unicodeString( "first_name" );
table.unicodeString( "last_name" );
table.unicodeString( "password", 100 );
table;
table
.unsignedInteger( "country_id" )
.references( "id" )
.onTable( "countries" )
.onDelete( "CASCADE" );
table.timestamp( "created_date" ).setDefault( "CURRENT_TIMESTAMP" );
table.timestamp( "modified_date" ).setDefault( "CURRENT_TIMESTAMP" );
},
@@ -1301,7 +1305,10 @@ component extends="testbox.system.BaseSpec" {
return schema.create(
"posts",
function( table ) {
table;
table
.unsignedInteger( "author_id" )
.references( "id" )
.onTable( "users" );
},
{},
false
@@ -1315,7 +1322,10 @@ component extends="testbox.system.BaseSpec" {
"posts",
function( table ) {
table.unsignedInteger( "author_id" );
table;
table
.foreignKey( "author_id" )
.references( "id" )
.onTable( "users" );
},
{},
false
@@ -1328,7 +1338,11 @@ component extends="testbox.system.BaseSpec" {
return schema.create(
"posts",
function( table ) {
table;
table
.unsignedInteger( "author_id" )
.references( "id" )
.onTable( "users" )
.setName( "fk_author" );
},
{},
false
@@ -1342,7 +1356,11 @@ component extends="testbox.system.BaseSpec" {
"posts",
function( table ) {
table.unsignedInteger( "author_id" );
table;
table
.foreignKey( "author_id" )
.references( "id" )
.onTable( "users" )
.setName( "fk_author" );
},
{},
false
@@ -25,10 +25,9 @@ component extends="testbox.system.BaseSpec" {
} );

it( "retreives bindings in a flat array", function() {
query {
query.join( "second", function( join ) {
join.where( "second.locale", "=", "en-US" );
}
).where( "first.quantity", ">=", 10 );
} ).where( "first.quantity", ">=", 10 );

var bindings = query.getBindings();
expect( bindings ).toBeArray();
@@ -46,10 +45,9 @@ component extends="testbox.system.BaseSpec" {
} );

it( "retreives a map of bindings", function() {
query {
query.join( "second", function( join ) {
join.where( "second.locale", "=", "en-US" );
}
).where( "first.quantity", ">=", "10" );
} ).where( "first.quantity", ">=", "10" );

var bindings = query.getRawBindings();

@@ -40,7 +40,14 @@ component extends="testbox.system.BaseSpec" {
} );

it( "can be specify the boolean combinator", function() {
query;
query
.where( "::some column::", "=", "::some value::" )
.where(
"::another column::",
"=",
"::another value::",
"or"
);
expect( query.getWheres() ).toBe( [
{
column: "::some column::",

0 comments on commit 90d1093

Please sign in to comment.