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 022cf04a
authored
Dec 29, 2013
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix postgres bug with blank creates
1 parent
e7521c4d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
2 deletions
lib/dialects/mariadb/query.js
lib/dialects/mysql/query.js
lib/dialects/postgres/query-generator.js
lib/dialects/postgres/query.js
lib/dialects/sqlite/query.js
test/associations/has-many.test.js
test/dao-factory/create.test.js
test/postgres/query-generator.test.js
lib/dialects/mariadb/query.js
View file @
022cf04
...
...
@@ -88,6 +88,7 @@ module.exports = (function() {
.
on
(
'error'
,
function
(
err
)
{
errorDetected
=
true
self
.
emit
(
'sql'
,
self
.
sql
)
err
.
sql
=
sql
self
.
emit
(
'error'
,
err
,
self
.
callee
)
})
.
on
(
'end'
,
function
(
info
)
{
...
...
lib/dialects/mysql/query.js
View file @
022cf04
...
...
@@ -27,6 +27,7 @@ module.exports = (function() {
this
.
emit
(
'sql'
,
this
.
sql
)
if
(
err
)
{
err
.
sql
=
sql
this
.
emit
(
'error'
,
err
,
this
.
callee
)
}
else
{
this
.
emit
(
'success'
,
this
.
formatResults
(
results
))
...
...
lib/dialects/postgres/query-generator.js
View file @
022cf04
...
...
@@ -256,9 +256,12 @@ module.exports = (function() {
},
insertQuery
:
function
(
tableName
,
attrValueHash
,
attributes
)
{
var
query
,
valueQuery
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>) RETURNING *;"
,
emptyQuery
=
"INSERT INTO <%= table %> DEFAULT VALUES RETURNING *;"
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>) RETURNING *;"
// Remove serials that are null or undefined, which causes an error in PG
Utils
.
_
.
forEach
(
attrValueHash
,
function
(
value
,
key
,
hash
)
{
if
(
tables
[
tableName
])
{
...
...
@@ -284,6 +287,8 @@ module.exports = (function() {
,
values
:
rowValues
.
join
(
","
)
}
query
=
replacements
.
attributes
.
length
?
valueQuery
:
emptyQuery
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
...
...
lib/dialects/postgres/query.js
View file @
022cf04
...
...
@@ -36,6 +36,7 @@ module.exports = (function() {
query
.
on
(
'error'
,
function
(
err
)
{
receivedError
=
true
err
.
sql
=
sql
self
.
emit
(
'error'
,
err
,
self
.
callee
)
})
...
...
lib/dialects/sqlite/query.js
View file @
022cf04
...
...
@@ -44,6 +44,7 @@ module.exports = (function() {
self
.
emit
(
'sql'
,
self
.
sql
)
if
(
err
)
{
err
.
sql
=
self
.
sql
onFailure
.
call
(
self
,
err
)
}
else
{
this
.
columnTypes
=
columnTypes
...
...
test/associations/has-many.test.js
View file @
022cf04
...
...
@@ -898,7 +898,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
this
.
sequelize
.
sync
().
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Worker
.
create
().
done
(
function
(
err
,
worker
)
{
Worker
.
create
(
{}
).
done
(
function
(
err
,
worker
)
{
expect
(
err
).
not
.
to
.
be
.
ok
Task
.
bulkCreate
([{},
{}]).
done
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
...
...
test/dao-factory/create.test.js
View file @
022cf04
...
...
@@ -595,6 +595,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'should allow blank creates (with timestamps: false)'
,
function
(
done
)
{
var
Worker
=
this
.
sequelize
.
define
(
'Worker'
,
{},
{
timestamps
:
false
})
Worker
.
sync
().
done
(
function
(
err
)
{
Worker
.
create
().
done
(
function
(
err
,
worker
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
worker
).
to
.
be
.
ok
done
()
})
})
})
describe
(
'enums'
,
function
()
{
it
(
'correctly restores enum values'
,
function
(
done
)
{
var
self
=
this
...
...
test/postgres/query-generator.test.js
View file @
022cf04
...
...
@@ -415,6 +415,10 @@ if (dialect.match(/^postgres/)) {
insertQuery
:
[
{
arguments
:
[
'myTable'
,
{}],
expectation
:
"INSERT INTO \"myTable\" DEFAULT VALUES RETURNING *;"
},
{
arguments
:
[
'myTable'
,
{
name
:
'foo'
}],
expectation
:
"INSERT INTO \"myTable\" (\"name\") VALUES ('foo') RETURNING *;"
},
{
...
...
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