Permalink
Browse files

Finished SELECT builder test.

  • Loading branch information...
1 parent 39996b4 commit d5d72033c7f7434331f760ffebd1e9718f4217c2 @hiddentao committed Nov 2, 2012
Showing with 392 additions and 146 deletions.
  1. +56 −63 docs/squel.html
  2. +44 −62 squel.js
  3. +1 −1 squel.min.js
  4. +17 −17 src/squel.coffee
  5. +3 −3 test/BaseQueryBuilders.test.coffee
  6. +271 −0 test/select.test.coffee
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
106 squel.js

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -251,14 +251,14 @@ class WhereOrderLimit extends QueryBuilder
# Get string representation of WHERE clause, if any
- whereString: =>
+ _whereString: =>
if 0 < @wheres.length
" WHERE (" + @wheres.join(") AND (") + ")"
else
""
# Get string representation of ORDER BY clause, if any
- orderString: =>
+ _orderString: =>
if 0 < @orders.length
orders = ""
for o in @orders
@@ -269,7 +269,7 @@ class WhereOrderLimit extends QueryBuilder
""
# Get string representation of LIMIT clause, if any
- limitString: =>
+ _limitString: =>
if @limits
" LIMIT #{@limits}"
else
@@ -323,7 +323,7 @@ class JoinWhereOrderLimit extends WhereOrderLimit
# Get string representation of JOIN clauses, if any
- joinString: =>
+ _joinString: =>
joins = ""
for j in (@joins or [])
@@ -381,7 +381,7 @@ class Select extends JoinWhereOrderLimit
alias = @_sanitizeAlias(alias) if alias
@fields.push
- field: field
+ name: field
alias: alias
@
@@ -419,7 +419,7 @@ class Select extends JoinWhereOrderLimit
fields = ""
for field in @fields
fields += ", " if "" isnt fields
- fields += field.field
+ fields += field.name
fields += " AS \"#{field.alias}\"" if field.alias
ret += if "" is fields then "*" else fields
@@ -434,10 +434,10 @@ class Select extends JoinWhereOrderLimit
ret += " FROM #{tables}"
# joins
- ret += @joinString()
+ ret += @_joinString()
# where
- ret += @whereString()
+ ret += @_whereString()
# group by
if 0 < @groups.length
@@ -448,10 +448,10 @@ class Select extends JoinWhereOrderLimit
ret += " GROUP BY #{groups}"
# order by
- ret += @orderString()
+ ret += @_orderString()
# limit
- ret += @limitString()
+ ret += @_limitString()
# offset
ret += " OFFSET #{@offsets}" if @offsets
@@ -525,13 +525,13 @@ class Update extends WhereOrderLimit
ret += " SET #{fields}"
# where
- ret += @whereString()
+ ret += @_whereString()
# order by
- ret += @orderString()
+ ret += @_orderString()
# limit
- ret += @limitString()
+ ret += @_limitString()
ret
@@ -561,16 +561,16 @@ class Delete extends JoinWhereOrderLimit
ret = "DELETE FROM #{@table}"
# joins
- ret += @joinString()
+ ret += @_joinString()
# where
- ret += @whereString()
+ ret += @_whereString()
# order by
- ret += @orderString()
+ ret += @_orderString()
# limit
- ret += @limitString()
+ ret += @_limitString()
ret
@@ -280,7 +280,7 @@ test['WhereOrderLimit base class'] =
assert.ok @inst._sanitizeField.calledWithExactly 'field'
assert.same [ { field: 'field', dir: 'ASC' } ], @inst.orders
- 'args (field2, false)':
+ '>> args (field2, false)':
beforeEach: ->
@ret = @inst.order("field2", false)
@@ -311,7 +311,7 @@ test['WhereOrderLimit base class'] =
assert.ok @inst._sanitizeLimitOffset.calledWithExactly 0
assert.same 0, @inst.limits
- 'args (2)':
+ '>> args (2)':
beforeEach: ->
@ret = @inst.limit(2)
@@ -400,7 +400,7 @@ test['JoinWhereOrderLimit base class'] =
assert.ok @inst._sanitizeAlias.notCalled
assert.ok @inst._sanitizeCondition.notCalled
- 'args(table2)': ->
+ '>> args(table2)': ->
assert.same @inst.join('table2'), @inst
assert.same @inst.joins, [
{
Oops, something went wrong.

0 comments on commit d5d7203

Please sign in to comment.