Skip to content

Commit

Permalink
Rename Quick to qb.
Browse files Browse the repository at this point in the history
Quick will be the ORM implementation that will use qb underneath the hood.
  • Loading branch information
Eric Peterson authored and Eric Peterson committed Dec 2, 2016
1 parent 657d47c commit 29b34af
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 76 deletions.
4 changes: 2 additions & 2 deletions ModuleConfig.cfc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
component {

this.title = 'Quick';
this.title = 'qb';
this.author = 'Eric Peterson';
this.webURL = 'https://github.com/elpete/quick';
this.description = 'Query builder for the rest of us';
this.version = '0.1.0';
this.autoMapModels = true;
this.cfmapping = 'Quick';
this.cfmapping = 'qb';

function configure() {
//
Expand Down
18 changes: 9 additions & 9 deletions models/Query/Builder.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ component displayname="Builder" accessors="true" {
};

public Builder function init(
Grammar grammar = new Quick.models.Query.Grammars.Grammar( ),
QueryUtils utils = new Quick.models.Query.QueryUtils()
Grammar grammar = new qb.models.Query.Grammars.Grammar( ),
QueryUtils utils = new qb.models.Query.QueryUtils()
) {
variables.grammar = arguments.grammar;
variables.utils = arguments.utils;
Expand Down Expand Up @@ -109,7 +109,7 @@ component displayname="Builder" accessors="true" {
string type = "inner",
boolean where = false
) {
var join = new Quick.models.Query.JoinClause(
var join = new qb.models.Query.JoinClause(
parentQuery = this,
type = arguments.type,
table = arguments.table
Expand Down Expand Up @@ -167,7 +167,7 @@ component displayname="Builder" accessors="true" {
}

variables.joins.append(
new Quick.models.Query.JoinClause( this, "cross", table )
new qb.models.Query.JoinClause( this, "cross", table )
);

return this;
Expand Down Expand Up @@ -223,7 +223,7 @@ component displayname="Builder" accessors="true" {
type = "basic"
} );

if ( ! isInstanceOf( arguments.value, "Quick.models.Query.Expression" ) ) {
if ( ! isInstanceOf( arguments.value, "qb.models.Query.Expression" ) ) {
addBindings( utils.extractBinding( arguments.value ), "where" );
}

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

// values.filter( function( value ) {
// return ! isInstanceOf( value, "Quick.models.Query.Expression" );
// return ! isInstanceOf( value, "qb.models.Query.Expression" );
// } ).each( function( value ) {
// var binding = utils.extractBinding( value );
// variables.bindings.where.append( binding );
Expand Down Expand Up @@ -590,7 +590,7 @@ component displayname="Builder" accessors="true" {
}

public Builder function newQuery() {
return new Quick.models.Query.Builder( grammar = getGrammar() );
return new qb.models.Query.Builder( grammar = getGrammar() );
}

public array function getBindings() {
Expand Down Expand Up @@ -634,7 +634,7 @@ component displayname="Builder" accessors="true" {
// Collaborators

public Expression function raw( required string sql ) {
return new quick.models.Query.Expression( sql );
return new qb.models.Query.Expression( sql );
}

public string function toSQL() {
Expand All @@ -660,7 +660,7 @@ component displayname="Builder" accessors="true" {
}

var arg = arguments[ 1 ];
if ( isInstanceOf( arg, "Quick.models.Query.Expression" ) ) {
if ( isInstanceOf( arg, "qb.models.Query.Expression" ) ) {
return [ arg ];
}

Expand Down
10 changes: 5 additions & 5 deletions models/Query/Grammars/Grammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ component displayname="Grammar" accessors="true" {
}

var whereList = wheresArray.toList( " " );
var conjunction = isInstanceOf( query, "Quick.models.Query.JoinClause" ) ?
var conjunction = isInstanceOf( query, "qb.models.Query.JoinClause" ) ?
"ON" : "WHERE";

return "#conjunction# #removeLeadingCombinator( whereList )#";
Expand All @@ -82,7 +82,7 @@ component displayname="Grammar" accessors="true" {

var placeholder = "?";

if ( isInstanceOf( where.value, "Quick.models.Query.Expression" ) ) {
if ( isInstanceOf( where.value, "qb.models.Query.Expression" ) ) {
placeholder = where.value.getSql();
}

Expand Down Expand Up @@ -133,7 +133,7 @@ component displayname="Grammar" accessors="true" {

private string function whereIn( required struct where, required Builder query ) {
var placeholderString = where.values.map( function( value ) {
return isInstanceOf( value, "Quick.models.Query.Expression" ) ? value.getSql() : "?";
return isInstanceOf( value, "qb.models.Query.Expression" ) ? value.getSql() : "?";
} ).toList( ", " );
if ( placeholderString == "" ) {
return "0 = 1";
Expand All @@ -143,7 +143,7 @@ component displayname="Grammar" accessors="true" {

private string function whereNotIn( required struct where, required Builder query ) {
var placeholderString = where.values.map( function( value ) {
return isInstanceOf( value, "Quick.models.Query.Expression" ) ? value.getSql() : "?";
return isInstanceOf( value, "qb.models.Query.Expression" ) ? value.getSql() : "?";
} ).toList( ", " );
if ( placeholderString == "" ) {
return "1 = 1";
Expand Down Expand Up @@ -231,7 +231,7 @@ component displayname="Grammar" accessors="true" {
}

private string function wrapColumn( required any column ) {
if ( isInstanceOf( column, "quick.models.Query.Expression" ) ) {
if ( isInstanceOf( column, "qb.models.Query.Expression" ) ) {
return column.getSQL();
}
var alias = "";
Expand Down
2 changes: 1 addition & 1 deletion models/Query/Grammars/GrammarInterface.cfc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface displayname="GrammarInterface" {
public string function compileSelect( required Quick.models.Query.Builder query );
public string function compileSelect( required qb.models.Query.Builder query );
}
12 changes: 6 additions & 6 deletions models/Query/Grammars/OracleGrammar.cfc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
component displayname="OracleGrammar" extends="Quick.models.Query.Grammars.Grammar" {
component displayname="OracleGrammar" extends="qb.models.Query.Grammars.Grammar" {

variables.selectComponents = [
"columns", "from", "joins", "wheres"
];

public string function compileSelect( required Quick.models.Query.Builder query ) {
public string function compileSelect( required qb.models.Query.Builder query ) {

var sql = [];

Expand All @@ -21,16 +21,16 @@ component displayname="OracleGrammar" extends="Quick.models.Query.Grammars.Gramm
return concatenate( sql );
}

private string function compileColumns( required Quick.models.Query.Builder query, required array columns ) {
private string function compileColumns( required qb.models.Query.Builder query, required array columns ) {
var select = query.getDistinct() ? "SELECT DISTINCT " : "SELECT ";
return select & arrayToList( columns );
}

private string function compileFrom( required Quick.models.Query.Builder query, required string from ) {
private string function compileFrom( required qb.models.Query.Builder query, required string from ) {
return "FROM " & from;
}

private string function compileJoins( required Quick.models.Query.Builder query, required array joins ) {
private string function compileJoins( required qb.models.Query.Builder query, required array joins ) {
var joinsArray = [];
for ( var join in arguments.joins ) {
var firstOne = true;
Expand All @@ -57,7 +57,7 @@ component displayname="OracleGrammar" extends="Quick.models.Query.Grammars.Gramm
return arrayToList( joinsArray, " " );
}

private string function compileWheres( required Quick.models.Query.Builder query, requierd array wheres ) {
private string function compileWheres( required qb.models.Query.Builder query, requierd array wheres ) {
var wheresArray = [];
var firstOne = true;
for ( var where in arguments.wheres ) {
Expand Down
6 changes: 3 additions & 3 deletions models/Query/JoinClause.cfc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
component displayname="JoinClause" extends="Quick.models.Query.Builder" accessors="true" {
component displayname="JoinClause" extends="qb.models.Query.Builder" accessors="true" {

property name="parentQuery" type="Quick.models.Query.Builder";
property name="parentQuery" type="qb.models.Query.Builder";
property name="type" type="string";
property name="table" type="string";

Expand Down Expand Up @@ -47,7 +47,7 @@ component displayname="JoinClause" extends="Quick.models.Query.Builder" accessor
}

public Builder function newQuery() {
return new Quick.models.Query.JoinClause(
return new qb.models.Query.JoinClause(
parentQuery = getParentQuery(),
type = getType(),
table = getTable()
Expand Down
4 changes: 2 additions & 2 deletions models/Query/QueryUtils.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ component displayname="QueryUtils" {
}

public boolean function isExpression( required any value ) {
return isInstanceOf( arguments.value, "Quick.models.Query.Expression" );
return isInstanceOf( arguments.value, "qb.models.Query.Expression" );
}

public boolean function isNotExpression( required any value ) {
return ! isInstanceOf( arguments.value, "Quick.models.Query.Expression" );
return ! isInstanceOf( arguments.value, "qb.models.Query.Expression" );
}

private string function normalizeSqlValue( required any value ) {
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions server-quick.json

This file was deleted.

4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "qb",
"web":{
"http":{
"port":"7777"
}
},
"openbrowser":false
}
}
2 changes: 1 addition & 1 deletion tests/Application.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component {
this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() );
this.mappings[ "/Quick" ] = expandPath( "/" );
this.mappings[ "/qb" ] = expandPath( "/" );
}
6 changes: 3 additions & 3 deletions tests/specs/Query/Builder+GrammarSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,11 @@ component extends="testbox.system.BaseSpec" {

private Builder function getBuilder() {
var builder = getMockBox()
.createMock( "Quick.models.Query.Builder" ).init();
.createMock( "qb.models.Query.Builder" ).init();
var grammar = getMockBox()
.createMock( "Quick.models.Query.Grammars.Grammar" );
.createMock( "qb.models.Query.Grammars.Grammar" );
var queryUtils = getMockBox()
.createMock( "Quick.models.Query.QueryUtils" );
.createMock( "qb.models.Query.QueryUtils" );
builder.$property( propertyName = "grammar", mock = grammar );
builder.$property( propertyName = "utils", mock = queryUtils );
return builder;
Expand Down
6 changes: 3 additions & 3 deletions tests/specs/Query/Builder/BuilderGetSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ component extends="testbox.system.BaseSpec" {
function run() {
describe( "get methods", function() {
beforeEach( function() {
variables.query = new Quick.models.Query.Builder();
variables.query = new qb.models.Query.Builder();
getMockBox().prepareMock( query );

var utils = new Quick.models.Query.QueryUtils();
var utils = new qb.models.Query.QueryUtils();
query.$property( propertyName = "utils", mock = utils );

var mockWirebox = getMockBox().createStub();
var mockJoinClause = getMockBox()
.prepareMock( new Quick.models.Query.JoinClause( query, "inner", "second" ) );
.prepareMock( new qb.models.Query.JoinClause( query, "inner", "second" ) );
mockJoinClause.$property( propertyName = "utils", mock = utils );
mockWirebox
.$( "getInstance" )
Expand Down
22 changes: 11 additions & 11 deletions tests/specs/Query/Builder/BuilderJoinSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ component extends="testbox.system.BaseSpec" {
function run() {
describe( "join methods", function() {
beforeEach( function() {
variables.query = new Quick.models.Query.Builder();
variables.query = new qb.models.Query.Builder();
getMockBox().prepareMock( query );
variables.utils = new Quick.models.Query.QueryUtils();
variables.utils = new qb.models.Query.QueryUtils();
query.$property( propertyName = "utils", mock = utils );
var mockJoinClause = getMockBox()
.prepareMock( new Quick.models.Query.JoinClause( query, "inner", "second" ) );
.prepareMock( new qb.models.Query.JoinClause( query, "inner", "second" ) );
mockJoinClause.$property( propertyName = "utils", mock = utils );
} );

it( "does a simple inner join", function() {
var mockJoinClause = getMockBox()
.prepareMock( new Quick.models.Query.JoinClause( query, "inner", "second" ) );
.prepareMock( new qb.models.Query.JoinClause( query, "inner", "second" ) );
mockJoinClause.$property( propertyName = "utils", mock = utils );

query.join( "second", "first.id", "=", "second.first_id" );
Expand All @@ -22,7 +22,7 @@ component extends="testbox.system.BaseSpec" {
expect( arrayLen( joins ) ).toBe( 1, "Only one join should exist" );

var join = joins[ 1 ];
expect( join ).toBeInstanceOf( "Quick.models.Query.JoinClause" );
expect( join ).toBeInstanceOf( "qb.models.Query.JoinClause" );
expect( join.getType() ).toBe( "inner" );
expect( join.getTable() ).toBe( "second" );

Expand All @@ -39,7 +39,7 @@ component extends="testbox.system.BaseSpec" {

it( "does a left join", function() {
var mockJoinClause = getMockBox()
.prepareMock( new Quick.models.Query.JoinClause( query, "left", "second" ) );
.prepareMock( new qb.models.Query.JoinClause( query, "left", "second" ) );
mockJoinClause.$property( propertyName = "utils", mock = utils );

query.leftJoin( "second", "first.id", "=", "second.first_id" );
Expand All @@ -48,7 +48,7 @@ component extends="testbox.system.BaseSpec" {
expect( arrayLen( joins ) ).toBe( 1, "Only one join should exist" );

var join = joins[ 1 ];
expect( join ).toBeInstanceOf( "Quick.models.Query.JoinClause" );
expect( join ).toBeInstanceOf( "qb.models.Query.JoinClause" );
expect( join.getType() ).toBe( "left" );
expect( join.getTable() ).toBe( "second" );

Expand All @@ -65,7 +65,7 @@ component extends="testbox.system.BaseSpec" {

it( "does a right join", function() {
var mockJoinClause = getMockBox()
.prepareMock( new Quick.models.Query.JoinClause( query, "right", "second" ) );
.prepareMock( new qb.models.Query.JoinClause( query, "right", "second" ) );
mockJoinClause.$property( propertyName = "utils", mock = utils );

query.rightJoin( "second", "first.id", "=", "second.first_id" );
Expand All @@ -74,7 +74,7 @@ component extends="testbox.system.BaseSpec" {
expect( arrayLen( joins ) ).toBe( 1, "Only one join should exist" );

var join = joins[ 1 ];
expect( join ).toBeInstanceOf( "Quick.models.Query.JoinClause" );
expect( join ).toBeInstanceOf( "qb.models.Query.JoinClause" );
expect( join.getType() ).toBe( "right" );
expect( join.getTable() ).toBe( "second" );

Expand All @@ -99,7 +99,7 @@ component extends="testbox.system.BaseSpec" {
expect( arrayLen( joins ) ).toBe( 1, "Only one join should exist" );

var join = joins[ 1 ];
expect( join ).toBeInstanceOf( "Quick.models.Query.JoinClause" );
expect( join ).toBeInstanceOf( "qb.models.Query.JoinClause" );
expect( join.getType() ).toBe( "inner" );
expect( join.getTable() ).toBe( "second" );

Expand Down Expand Up @@ -131,7 +131,7 @@ component extends="testbox.system.BaseSpec" {
expect( arrayLen( joins ) ).toBe( 1, "Only one join should exist" );

var join = joins[ 1 ];
expect( join ).toBeInstanceOf( "Quick.models.Query.JoinClause" );
expect( join ).toBeInstanceOf( "qb.models.Query.JoinClause" );
expect( join.getType() ).toBe( "inner" );
expect( join.getTable() ).toBe( "second" );

Expand Down
4 changes: 2 additions & 2 deletions tests/specs/Query/Builder/BuilderSelectSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ component extends="testbox.system.BaseSpec" {
function run() {
describe( "select methods", function() {
beforeEach( function() {
variables.mockGrammar = getMockBox().createMock( "Quick.models.Query.Grammars.Grammar" );
variables.query = new Quick.models.Query.Builder( variables.mockGrammar );
variables.mockGrammar = getMockBox().createMock( "qb.models.Query.Grammars.Grammar" );
variables.query = new qb.models.Query.Builder( variables.mockGrammar );
} );

describe( "select()", function() {
Expand Down
6 changes: 3 additions & 3 deletions tests/specs/Query/Builder/BuilderWhereSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ component extends="testbox.system.BaseSpec" {
function run() {
describe( "where methods", function() {
beforeEach( function() {
variables.query = new Quick.models.Query.Builder();
variables.query = new qb.models.Query.Builder();
getMockBox().prepareMock( query );
query.$property( propertyName = "utils", mock = new Quick.models.Query.QueryUtils() );
query.$property( propertyName = "utils", mock = new qb.models.Query.QueryUtils() );
} );

it( "defaults to empty", function() {
Expand Down Expand Up @@ -137,7 +137,7 @@ component extends="testbox.system.BaseSpec" {

it( "returns the query instance to continue chaining", function() {
var q = query.whereSomeColumn( "::some value::" );
expect( q ).toBeInstanceOf( "Quick.models.Query.Builder" );
expect( q ).toBeInstanceOf( "qb.models.Query.Builder" );
} );
} );

Expand Down
Loading

0 comments on commit 29b34af

Please sign in to comment.