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 263ddba0
authored
Jan 13, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model#findOrCreate): escape $ inside insertQuery
1 parent
ce6f5729
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
CONTRIBUTING.md
lib/dialects/abstract/query-generator.js
test/model/create.test.js
CONTRIBUTING.md
View file @
263ddba
...
@@ -74,8 +74,12 @@ $ sudo docker pull mhansen/sequelize-contribution
...
@@ -74,8 +74,12 @@ $ sudo docker pull mhansen/sequelize-contribution
Start the container and save references to container id and ip:
Start the container and save references to container id and ip:
```
console
```
console
#
Start
mysql/postgres container
$
CONTAINER=$(sudo
docker run -d -i -t mhansen/sequelize-contribution)
$
CONTAINER=$(sudo
docker run -d -i -t mhansen/sequelize-contribution)
$
CONTAINER_IP=$(sudo
docker inspect -format='{{.NetworkSettings.IPAddress}}' $CONTAINER)
#
Or
start postgres 9.4 container
$
CONTAINER=$(sudo
docker run --name sequelize-postgres -e POSTGRES_USER=sequelize_test -e POSTGRES_PASSWORD=sequelize_test -d postgres:9.4)
$
CONTAINER_IP=$(sudo
docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER)
```
```
Run tests:
Run tests:
...
...
lib/dialects/abstract/query-generator.js
View file @
263ddba
...
@@ -238,7 +238,12 @@ module.exports = (function() {
...
@@ -238,7 +238,12 @@ module.exports = (function() {
identityWrapperRequired
=
true
;
identityWrapperRequired
=
true
;
}
}
values
.
push
(
this
.
escape
(
value
,
(
modelAttributeMap
&&
modelAttributeMap
[
key
])
||
undefined
));
value
=
this
.
escape
(
value
,
(
modelAttributeMap
&&
modelAttributeMap
[
key
])
||
undefined
);
if
(
options
.
exception
)
{
// $ inside value strings are illegal when using $$ as literal strings/delimiters for function bodys
value
=
value
.
replace
(
/
\$
/g
,
'\\$'
);
}
values
.
push
(
value
);
}
}
}
}
}
}
...
...
test/model/create.test.js
View file @
263ddba
...
@@ -107,6 +107,29 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -107,6 +107,29 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
});
it
(
'should support special characters in defaults'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'user'
,
{
objectId
:
{
type
:
DataTypes
.
INTEGER
,
unique
:
true
},
description
:
{
type
:
DataTypes
.
TEXT
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
findOrCreate
({
where
:
{
objectId
:
1
},
defaults
:
{
description
:
'$$ and !! and :: and ? and ^ and * and \''
}
});
});
});
it
(
'returns instance if already existent. Single find field.'
,
function
(
done
)
{
it
(
'returns instance if already existent. Single find field.'
,
function
(
done
)
{
var
self
=
this
,
var
self
=
this
,
data
=
{
data
=
{
...
...
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