From 4508abbee3e20044fca7522cd0c8f5ef2b6a01bf Mon Sep 17 00:00:00 2001 From: welefen Date: Tue, 16 Sep 2014 14:46:14 +0800 Subject: [PATCH] =?UTF-8?q?Model=E6=B7=BB=E5=8A=A0=E5=AD=90=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Lib/Core/Model.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Lib/Core/Model.js b/test/Lib/Core/Model.js index ce09c8e0..7a1dab7a 100644 --- a/test/Lib/Core/Model.js +++ b/test/Lib/Core/Model.js @@ -1470,6 +1470,18 @@ describe('Model', function(){ }) }) + describe('child select', function(){ + it('cate lastest', function(done){ + var instance = D('Pic1'); + return instance.order('id DESC').buildSql().then(function(sql){ + return instance.table(sql, true).alias('tmp').group('group_id').order('id DESC').select().then(function(){ + var sql = instance.getLastSql().trim(); + assert.equal(sql, "SELECT * FROM ( SELECT * FROM `think_pic1` ORDER BY id DESC ) AS tmp GROUP BY `group_id` ORDER BY id DESC"); + done(); + }) + }) + }) + }) }); describe('after', function(){