1 |
|
2 |
|
3 | require('../../src/dev/test/init');
|
4 |
|
5 | var assert = require('assert');
|
6 | var _ = require('lodash');
|
7 |
|
8 | var Query = require('../../src/db/Query');
|
9 |
|
10 | describe('db.Query', function() {
|
11 |
|
12 | class Book {
|
13 |
|
14 | };
|
15 | Book.schema = {
|
16 | table: 'books',
|
17 | primary: ['id']
|
18 | };
|
19 |
|
20 |
|
21 | describe('first', function() {
|
22 | it('should return correct SQL', function() {
|
23 | var first = new Query(Book).first();
|
24 | var sql = 'SELECT `books`.* FROM `books` ORDER BY `id` ASC LIMIT ?, ?';
|
25 | assert.equal(sql, first.query.generated.sql);
|
26 | });
|
27 | });
|
28 | });
|