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 3d1ef1ee
authored
Nov 19, 2014
by
Matt Broadstone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a few things missed in the "great cherry-pick"
1 parent
6e13407a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
13 deletions
lib/dialects/mssql/query-generator.js
lib/dialects/mssql/query.js
test/model.test.js
test/sequelize.test.js
lib/dialects/mssql/query-generator.js
View file @
3d1ef1e
...
...
@@ -1468,7 +1468,22 @@ module.exports = (function() {
booleanValue
:
function
(
value
)
{
return
value
;
}
},
uniqueConstraintMapping
:
{
code
:
'EREQUEST'
,
map
:
function
(
str
)
{
// we're manually remvoving uniq_ here for a future capability of defining column names explicitly
var
match
=
str
.
match
(
/Violation of UNIQUE KEY constraint '
(
.*
)
'. Cannot insert duplicate key in object '
?(
.*
?)
$/
);
if
(
match
===
null
||
match
.
length
<
2
)
{
return
false
;
}
return
{
indexName
:
match
[
1
],
fields
:
match
[
1
].
split
(
'_'
)
};
}
},
};
/* istanbul ignore next */
...
...
lib/dialects/mssql/query.js
View file @
3d1ef1e
...
...
@@ -220,7 +220,7 @@ module.exports = (function() {
});
};
Abstract
Query
.
prototype
.
handleInsertQuery
=
function
(
results
,
metaData
)
{
Query
.
prototype
.
handleInsertQuery
=
function
(
results
,
metaData
)
{
if
(
this
.
callee
)
{
// add the inserted row id to the instance
var
autoIncrementField
=
this
.
callee
.
Model
.
autoIncrementField
...
...
test/model.test.js
View file @
3d1ef1e
...
...
@@ -354,9 +354,10 @@ describe(Support.getTestDialectTeaser("Model"), function () {
}
});
});
})
});
it
(
'allows us to customize the error message for unique constraint'
,
function
()
{
if
(
dialect
!==
'mssql'
?
it
:
it
.
skip
)(
'allows us to customize the error message for unique constraint'
,
function
(
done
)
{
var
self
=
this
,
User
=
this
.
sequelize
.
define
(
'UserWithUniqueUsername'
,
{
username
:
{
type
:
Sequelize
.
STRING
,
unique
:
{
name
:
'user_and_email'
,
msg
:
'User and email must be unique'
}},
...
...
test/sequelize.test.js
View file @
3d1ef1e
...
...
@@ -17,7 +17,7 @@ var chai = require('chai')
chai
.
config
.
includeStack
=
true
var
qq
=
function
(
str
)
{
if
(
dialect
==
'postgres'
||
dialect
==
'sqlite'
)
{
if
(
dialect
==
'postgres'
||
dialect
==
'sqlite'
||
dialect
===
'mssql'
)
{
return
'"'
+
str
+
'"'
}
else
if
(
Support
.
dialectIsMySQL
())
{
return
'`'
+
str
+
'`'
...
...
@@ -108,7 +108,6 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
it
(
'triggers the actual adapter error'
,
function
(
done
)
{
this
.
sequelizeWithInvalidConnection
.
authenticate
()
...
...
@@ -331,7 +330,7 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
it
(
'dot separated attributes when doing a raw query without nest'
,
function
(
done
)
{
var
tickChar
=
(
dialect
===
'postgres'
)
?
'"'
:
'`'
var
tickChar
=
(
dialect
===
'postgres'
||
dialect
===
'mssql'
)
?
'"'
:
'`'
,
sql
=
"select 1 as "
+
Sequelize
.
Utils
.
addTicks
(
'foo.bar.baz'
,
tickChar
)
this
.
sequelize
.
query
(
sql
,
null
,
{
raw
:
true
,
nest
:
false
}).
success
(
function
(
result
)
{
...
...
@@ -341,7 +340,7 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
it
(
'destructs dot separated attributes when doing a raw query using nest'
,
function
(
done
)
{
var
tickChar
=
(
dialect
===
'postgres'
)
?
'"'
:
'`'
var
tickChar
=
(
dialect
===
'postgres'
||
dialect
===
'mssql'
)
?
'"'
:
'`'
,
sql
=
"select 1 as "
+
Sequelize
.
Utils
.
addTicks
(
'foo.bar.baz'
,
tickChar
)
this
.
sequelize
.
query
(
sql
,
null
,
{
raw
:
true
,
nest
:
true
}).
success
(
function
(
result
)
{
...
...
@@ -426,11 +425,16 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
it
(
'handles AS in conjunction with functions just fine'
,
function
(
done
)
{
this
.
sequelize
.
query
(
'SELECT '
+
(
dialect
===
"sqlite"
?
'date(\'now\')'
:
'NOW()'
)
+
' AS t'
).
success
(
function
(
result
)
{
var
datetime
=
(
dialect
===
"sqlite"
?
'date(\'now\')'
:
'NOW()'
);
if
(
dialect
===
"mssql"
)
{
datetime
=
"GETDATE()"
}
this
.
sequelize
.
query
(
'SELECT '
+
datetime
+
' AS t'
).
success
(
function
(
result
)
{
expect
(
moment
(
result
[
0
].
t
).
isValid
()).
to
.
be
.
true
done
()
})
})
})
;
})
;
if
(
Support
.
getTestDialect
()
===
'postgres'
)
{
it
(
'replaces named parameters with the passed object and ignores casts'
,
function
(
done
)
{
...
...
@@ -619,7 +623,7 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
var
User2
=
this
.
sequelizeWithInvalidCredentials
.
define
(
'User'
,
{
name
:
DataTypes
.
STRING
,
bio
:
DataTypes
.
TEXT
})
User2
.
sync
().
error
(
function
(
err
)
{
User2
.
sync
().
done
(
function
(
err
)
{
if
(
dialect
===
"postgres"
||
dialect
===
"postgres-native"
)
{
assert
([
'fe_sendauth: no password supplied'
,
...
...
@@ -627,9 +631,12 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
'FATAL: role "bar" does not exist'
,
'password authentication failed for user "bar"'
].
indexOf
(
err
.
message
.
trim
())
!==
-
1
)
}
else
if
(
dialect
===
'mssql'
)
{
expect
(
err
.
message
).
to
.
match
(
/.*ECONNREFUSED.*/
);
}
else
{
expect
(
err
.
message
.
toString
()).
to
.
match
(
/.*Access
\
denied.*/
)
expect
(
err
.
message
.
toString
()).
to
.
match
(
/.*Access
\
denied.*/
)
;
}
done
()
})
})
...
...
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