Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit e913ba3f
authored
Dec 06, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:sequelize/sequelize
2 parents
94d1b122
34f4f8c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
45 deletions
lib/dialects/abstract/index.js
test/dao-factory/update.test.js
test/promise.test.js
lib/dialects/abstract/index.js
View file @
e913ba3
...
@@ -34,6 +34,7 @@ AbstractDialect.prototype.supports = {
...
@@ -34,6 +34,7 @@ AbstractDialect.prototype.supports = {
schemas
:
false
,
schemas
:
false
,
transactions
:
true
,
transactions
:
true
,
migrations
:
true
,
migrations
:
true
,
upserts
:
true
,
constraints
:
{
constraints
:
{
restrict
:
true
restrict
:
true
},
},
...
...
test/dao-factory/update.test.js
View file @
e913ba3
...
@@ -12,7 +12,8 @@ var chai = require('chai')
...
@@ -12,7 +12,8 @@ var chai = require('chai')
,
dialect
=
Support
.
getTestDialect
()
,
dialect
=
Support
.
getTestDialect
()
,
datetime
=
require
(
'chai-datetime'
)
,
datetime
=
require
(
'chai-datetime'
)
,
_
=
require
(
'lodash'
)
,
_
=
require
(
'lodash'
)
,
assert
=
require
(
'assert'
);
,
assert
=
require
(
'assert'
)
,
current
=
Support
.
sequelize
;
chai
.
use
(
datetime
);
chai
.
use
(
datetime
);
chai
.
config
.
includeStack
=
true
;
chai
.
config
.
includeStack
=
true
;
...
@@ -40,55 +41,58 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -40,55 +41,58 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
clock
.
restore
();
this
.
clock
.
restore
();
});
});
describe
(
'upsert'
,
function
()
{
if
(
current
.
dialect
.
supports
.
upserts
)
{
it
(
'works with upsert on id'
,
function
()
{
describe
(
'upsert'
,
function
()
{
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
it
(
'works with upsert on id'
,
function
()
{
if
(
dialect
===
'sqlite'
)
{
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
if
(
dialect
===
'sqlite'
)
{
}
else
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
to
.
be
.
ok
;
}
else
{
}
expect
(
created
).
to
.
be
.
ok
;
}
this
.
clock
.
tick
(
2000
);
// Make sure to pass some time so updatedAt != createdAt
this
.
clock
.
tick
(
2000
);
// Make sure to pass some time so updatedAt != createdAt
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'doe'
});
return
this
.
User
.
upsert
({
id
:
42
,
username
:
'doe'
});
}).
then
(
function
(
created
)
{
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
not
.
to
.
be
.
defined
;
}
else
{
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
expect
(
created
).
not
.
to
.
be
.
ok
;
}
}
return
this
.
User
.
find
(
42
);
return
this
.
User
.
find
(
42
);
}).
then
(
function
(
user
)
{
}).
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
});
});
});
});
it
(
'works with upsert on a composite key'
,
function
()
{
it
(
'works with upsert on a composite key'
,
function
()
{
return
this
.
User
.
upsert
({
foo
:
'baz'
,
bar
:
19
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
return
this
.
User
.
upsert
({
foo
:
'baz'
,
bar
:
19
,
username
:
'john'
}).
bind
(
this
).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
not
.
to
.
be
.
defined
;
}
else
{
}
else
{
expect
(
created
).
to
.
be
.
ok
;
expect
(
created
).
to
.
be
.
ok
;
}
}
this
.
clock
.
tick
(
2000
);
// Make sure to pass some time so updatedAt != createdAt
this
.
clock
.
tick
(
2000
);
// Make sure to pass some time so updatedAt != createdAt
return
this
.
User
.
upsert
({
foo
:
'baz'
,
bar
:
19
,
username
:
'doe'
});
return
this
.
User
.
upsert
({
foo
:
'baz'
,
bar
:
19
,
username
:
'doe'
});
}).
then
(
function
(
created
)
{
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
not
.
to
.
be
.
defined
;
expect
(
created
).
not
.
to
.
be
.
defined
;
}
else
{
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
expect
(
created
).
not
.
to
.
be
.
ok
;
}
}
return
this
.
User
.
find
({
where
:
{
foo
:
'baz'
,
bar
:
19
}});
return
this
.
User
.
find
({
where
:
{
foo
:
'baz'
,
bar
:
19
}});
}).
then
(
function
(
user
)
{
}).
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
createdAt
).
to
.
be
.
defined
;
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
username
).
to
.
equal
(
'doe'
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
expect
(
user
.
updatedAt
).
to
.
be
.
afterTime
(
user
.
createdAt
);
});
});
});
});
});
});
}
});
});
test/promise.test.js
View file @
e913ba3
...
@@ -232,7 +232,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
...
@@ -232,7 +232,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
.
then
(
function
()
{
.
then
(
function
()
{
return
Book
return
Book
.
find
({
.
find
({
where
:
(
dialect
===
'postgres'
?
'"Book"."id"='
:
'`Book`.`id`='
)
+
book
.
id
,
where
:
{
id
:
book
.
id
}
,
include
:
[
Page
]
include
:
[
Page
]
})
})
.
then
(
function
(
leBook
)
{
.
then
(
function
(
leBook
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment