Merge branch 'master' into gh-pages

* master:
  minor fixes for the unit tests
This commit is contained in:
Tim Griesser 2013-09-13 18:11:59 -04:00
commit 4daba91303
4 changed files with 80 additions and 109 deletions

View File

@ -31,6 +31,7 @@ module.exports = function(knex) {
.logMe()
.join('accounts as a2', 'a2.email', '<>', 'accounts.email')
.select(['accounts.email as e1', 'a2.email as e2'])
.where('a2.email', 'test2@example.com')
.limit(5);
});
@ -42,6 +43,7 @@ module.exports = function(knex) {
.join('accounts as a2', function() {
this.on('accounts.email', '<>', 'a2.email').orOn('accounts.id','=',2);
})
.where('a2.email', 'test2@example.com')
.select(['accounts.email as e1', 'a2.email as e2'])
.limit(5);
});

View File

@ -74,7 +74,7 @@ module.exports = function(knex) {
it('allows adding a field', function (done) {
return knex.schema.table('test_table_two', function(t) {
t.json('json_data').nullable();
}).logMe('sql');
});
});
it('allows changing a field', function() {
@ -89,7 +89,7 @@ module.exports = function(knex) {
describe('hasTable', function() {
it('checks whether a table exists', function() {
return knex.schema.hasTable('test_table_two').logMe().then(function(resp) {
return knex.schema.hasTable('test_table_two').then(function(resp) {
expect(resp).to.be.true;
});
});

View File

@ -86,8 +86,8 @@ module.exports = {
email: 'test@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549602,
updated_at: 1379108549602,
created_at: 1379110284039,
updated_at: 1379110284039,
phone: null,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.'
},{
@ -97,8 +97,8 @@ module.exports = {
email: 'test2@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.'
},{
@ -108,8 +108,8 @@ module.exports = {
email: 'test3@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
details: ''
}]
@ -268,8 +268,8 @@ module.exports = {
email: 'test@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549602,
updated_at: 1379108549602,
created_at: 1379110284039,
updated_at: 1379110284039,
phone: null,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.'
},{
@ -279,8 +279,8 @@ module.exports = {
email: 'test2@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.'
},{
@ -290,8 +290,8 @@ module.exports = {
email: 'test3@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
details: ''
},{
@ -301,8 +301,8 @@ module.exports = {
email: 'test4@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549606,
updated_at: 1379108549606,
created_at: 1379110284044,
updated_at: 1379110284044,
phone: null,
details: null
},{
@ -312,8 +312,8 @@ module.exports = {
email: 'test5@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549606,
updated_at: 1379108549606,
created_at: 1379110284044,
updated_at: 1379110284044,
phone: null,
details: null
},{
@ -323,8 +323,8 @@ module.exports = {
email: 'test6@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549608,
updated_at: 1379108549608,
created_at: 1379110284046,
updated_at: 1379110284046,
phone: null,
details: null
}]
@ -519,8 +519,8 @@ module.exports = {
email: 'test@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549602,
updated_at: 1379108549602,
created_at: 1379110284039,
updated_at: 1379110284039,
phone: null,
account_id: 1,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.',
@ -533,8 +533,8 @@ module.exports = {
email: 'test2@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
account_id: 2,
details: 'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.',
@ -547,8 +547,8 @@ module.exports = {
email: 'test3@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549604,
updated_at: 1379108549604,
created_at: 1379110284041,
updated_at: 1379110284041,
phone: null,
account_id: 3,
details: '',
@ -561,8 +561,8 @@ module.exports = {
email: 'test4@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549606,
updated_at: 1379108549606,
created_at: 1379110284044,
updated_at: 1379110284044,
phone: null,
account_id: null,
details: null,
@ -575,8 +575,8 @@ module.exports = {
email: 'test5@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549606,
updated_at: 1379108549606,
created_at: 1379110284044,
updated_at: 1379110284044,
phone: null,
account_id: null,
details: null,
@ -589,8 +589,8 @@ module.exports = {
email: 'test6@example.com',
logins: 2,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: 1379108549608,
updated_at: 1379108549608,
created_at: 1379110284046,
updated_at: 1379110284046,
phone: null,
account_id: null,
details: null,
@ -601,8 +601,8 @@ module.exports = {
},
'supports join aliases': {
mysql: {
bindings: [],
sql: 'select `accounts`.`email` as `e1`, `a2`.`email` as `e2` from `accounts` inner join `accounts` as `a2` on `a2`.`email` <> `accounts`.`email` limit 5',
bindings: ['test2@example.com'],
sql: 'select `accounts`.`email` as `e1`, `a2`.`email` as `e2` from `accounts` inner join `accounts` as `a2` on `a2`.`email` <> `accounts`.`email` where `a2`.`email` = ? limit 5',
result: [{
e1: 'test3@example.com',
e2: 'test2@example.com'
@ -621,50 +621,50 @@ module.exports = {
}]
},
postgresql: {
bindings: [],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "a2"."email" <> "accounts"."email" limit 5',
bindings: ['test2@example.com'],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "a2"."email" <> "accounts"."email" where "a2"."email" = ? limit 5',
result: [{
e1: 'test@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test3@example.com'
e1: 'test3@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test4@example.com'
e1: 'test4@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test5@example.com'
e1: 'test5@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test6@example.com'
e1: 'test6@example.com',
e2: 'test2@example.com'
}]
},
sqlite3: {
bindings: [],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "a2"."email" <> "accounts"."email" limit 5',
bindings: ['test2@example.com'],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "a2"."email" <> "accounts"."email" where "a2"."email" = ? limit 5',
result: [{
e1: 'test2@example.com',
e2: 'test3@example.com'
e1: 'test3@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test4@example.com'
e1: 'test4@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test5@example.com'
e1: 'test5@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test6@example.com'
e1: 'test6@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test@example.com'
e1: 'test@example.com',
e2: 'test2@example.com'
}]
}
},
'supports join aliases with advanced joins': {
mysql: {
bindings: [],
sql: 'select `accounts`.`email` as `e1`, `a2`.`email` as `e2` from `accounts` inner join `accounts` as `a2` on `accounts`.`email` <> `a2`.`email` or `accounts`.`id` = 2 limit 5',
bindings: ['test2@example.com'],
sql: 'select `accounts`.`email` as `e1`, `a2`.`email` as `e2` from `accounts` inner join `accounts` as `a2` on `accounts`.`email` <> `a2`.`email` or `accounts`.`id` = 2 where `a2`.`email` = ? limit 5',
result: [{
e1: 'test2@example.com',
e2: 'test2@example.com'
@ -683,43 +683,43 @@ module.exports = {
}]
},
postgresql: {
bindings: [],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "accounts"."email" <> "a2"."email" or "accounts"."id" = 2 limit 5',
bindings: ['test2@example.com'],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "accounts"."email" <> "a2"."email" or "accounts"."id" = 2 where "a2"."email" = ? limit 5',
result: [{
e1: 'test@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test3@example.com'
e1: 'test2@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test4@example.com'
e1: 'test3@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test5@example.com'
e1: 'test4@example.com',
e2: 'test2@example.com'
},{
e1: 'test@example.com',
e2: 'test6@example.com'
e1: 'test5@example.com',
e2: 'test2@example.com'
}]
},
sqlite3: {
bindings: [],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "accounts"."email" <> "a2"."email" or "accounts"."id" = 2 limit 5',
bindings: ['test2@example.com'],
sql: 'select "accounts"."email" as "e1", "a2"."email" as "e2" from "accounts" inner join "accounts" as "a2" on "accounts"."email" <> "a2"."email" or "accounts"."id" = 2 where "a2"."email" = ? limit 5',
result: [{
e1: 'test2@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test3@example.com'
e1: 'test3@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test4@example.com'
e1: 'test4@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test5@example.com'
e1: 'test5@example.com',
e2: 'test2@example.com'
},{
e1: 'test2@example.com',
e2: 'test6@example.com'
e1: 'test6@example.com',
e2: 'test2@example.com'
}]
}
}

View File

@ -82,36 +82,5 @@ module.exports = {
bindings: [],
sql: ['create table "test_foreign_table_two" ("id" integer primary key autoincrement not null, "fkey_two" integer, foreign key("fkey_two") references "test_table_two"("id"), foreign key("fkey_two") references "test_table_two"("id"))']
}
},
'allows adding a field': {
mysql: {
bindings: [],
sql: ['alter table `test_table_two` add `json_data` text','alter table `test_table_two` add `json_data` text']
},
postgresql: {
bindings: [],
sql: ['alter table "test_table_two" add column "json_data" json','alter table "test_table_two" add column "json_data" json']
},
sqlite3: {
bindings: [],
sql: ['alter table "test_table_two" add column "json_data" text','alter table "test_table_two" add column "json_data" text']
}
},
'checks whether a table exists': {
mysql: {
bindings: ['db_test','db_test','test_table_two'],
sql: ['select * from information_schema.tables where table_schema = ? and table_name = ?'],
result: true
},
postgresql: {
bindings: ['test_table_two'],
sql: ['select * from information_schema.tables where table_name = ?'],
result: true
},
sqlite3: {
bindings: ['test_table_two'],
sql: ['select * from sqlite_master where type = \'table\' and name = ?'],
result: true
}
}
};