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 5ef2a954
authored
Feb 27, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'parse-dot-results' of
git://github.com/kozze89/sequelize
into kozz…
…e89-parse-dot-results
2 parents
62ad873a
7412958b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
19 deletions
lib/dialects/abstract/query.js
package.json
spec/sequelize.spec.js
lib/dialects/abstract/query.js
View file @
5ef2a95
var
Utils
=
require
(
'../../utils'
)
var
Utils
=
require
(
'../../utils'
)
,
CustomEventEmitter
=
require
(
"../../emitters/custom-event-emitter"
)
,
CustomEventEmitter
=
require
(
"../../emitters/custom-event-emitter"
)
,
Dot
=
require
(
'dottie'
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
AbstractQuery
=
function
(
database
,
sequelize
,
callee
,
options
)
{}
var
AbstractQuery
=
function
(
database
,
sequelize
,
callee
,
options
)
{}
...
@@ -222,7 +223,7 @@ module.exports = (function() {
...
@@ -222,7 +223,7 @@ module.exports = (function() {
var
result
=
null
,
self
=
this
;
var
result
=
null
,
self
=
this
;
if
(
this
.
options
.
raw
)
{
if
(
this
.
options
.
raw
)
{
result
=
results
result
=
results
.
map
(
Dot
.
transform
)
}
else
if
(
this
.
options
.
hasJoin
===
true
)
{
}
else
if
(
this
.
options
.
hasJoin
===
true
)
{
result
=
prepareJoinData
.
call
(
this
,
results
)
result
=
prepareJoinData
.
call
(
this
,
results
)
result
=
groupDataByCalleeFactory
.
call
(
this
,
result
).
map
(
function
(
result
)
{
result
=
groupDataByCalleeFactory
.
call
(
this
,
result
).
map
(
function
(
result
)
{
...
...
package.json
View file @
5ef2a95
...
@@ -28,7 +28,8 @@
...
@@ -28,7 +28,8 @@
"validator"
:
"0.4.x"
,
"validator"
:
"0.4.x"
,
"moment"
:
"~1.7.0"
,
"moment"
:
"~1.7.0"
,
"commander"
:
"~0.6.0"
,
"commander"
:
"~0.6.0"
,
"generic-pool"
:
"1.0.9"
"generic-pool"
:
"1.0.9"
,
"dottie"
:
"0.0.6-1"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"jasmine-node"
:
"1.0.17"
,
"jasmine-node"
:
"1.0.17"
,
...
...
spec/sequelize.spec.js
View file @
5ef2a95
...
@@ -6,8 +6,10 @@ if(typeof require === 'function') {
...
@@ -6,8 +6,10 @@ if(typeof require === 'function') {
}
}
var
qq
=
function
(
str
)
{
var
qq
=
function
(
str
)
{
if
(
dialect
==
'postgres'
)
{
if
(
dialect
==
'postgres'
||
dialect
==
'sqlite'
)
{
return
'"'
+
str
+
'"'
return
'"'
+
str
+
'"'
}
else
if
(
dialect
==
'mysql'
)
{
return
'`'
+
str
+
'`'
}
else
{
}
else
{
return
str
return
str
}
}
...
@@ -52,40 +54,54 @@ describe(Helpers.getTestDialectTeaser("Sequelize"), function() {
...
@@ -52,40 +54,54 @@ describe(Helpers.getTestDialectTeaser("Sequelize"), function() {
})
})
it
(
'executes a query the internal way'
,
function
(
done
)
{
it
(
'executes a query the internal way'
,
function
(
done
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
,
null
,
{
raw
:
true
}).
success
(
function
(
result
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
,
null
,
{
raw
:
true
})
.
complete
(
function
(
err
,
result
)
{
if
(
err
)
{
console
.
log
(
err
)
}
expect
(
err
).
toBeNull
()
expect
(
result
).
toBeNull
()
expect
(
result
).
toBeNull
()
done
()
done
()
})
})
.
error
(
function
(
err
)
{
console
.
log
(
err
)
expect
(
err
).
not
.
toBeDefined
()
done
()
})
})
})
it
(
'executes a query if only the sql is passed'
,
function
(
done
)
{
it
(
'executes a query if only the sql is passed'
,
function
(
done
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
).
success
(
function
(
result
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
)
.
complete
(
function
(
err
,
result
)
{
if
(
err
)
{
console
.
log
(
err
)
}
expect
(
err
).
toBeNull
()
expect
(
result
).
not
.
toBeDefined
()
expect
(
result
).
not
.
toBeDefined
()
done
()
done
()
})
})
.
error
(
function
(
err
)
{
console
.
log
(
err
)
expect
(
err
).
not
.
toBeDefined
()
done
()
})
})
})
it
(
'executes select queries correctly'
,
function
(
done
)
{
it
(
'executes select queries correctly'
,
function
(
done
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
).
success
(
function
()
{
this
.
sequelize
.
query
(
this
.
insertQuery
).
success
(
function
()
{
this
.
sequelize
this
.
sequelize
.
query
(
"select * from "
+
qq
(
this
.
User
.
tableName
)
+
""
)
.
query
(
"select * from "
+
qq
(
this
.
User
.
tableName
)
+
""
)
.
success
(
function
(
users
)
{
.
complete
(
function
(
err
,
users
)
{
if
(
err
)
{
console
.
log
(
err
)
}
expect
(
err
).
toBeNull
()
expect
(
users
.
map
(
function
(
u
){
return
u
.
username
})).
toEqual
([
'john'
])
expect
(
users
.
map
(
function
(
u
){
return
u
.
username
})).
toEqual
([
'john'
])
done
()
done
()
})
})
.
error
(
function
(
err
)
{
}.
bind
(
this
))
console
.
log
(
err
)
})
expect
(
err
).
not
.
toBeDefined
()
it
(
'executes select query and parses dot notation results'
,
function
(
done
)
{
this
.
sequelize
.
query
(
this
.
insertQuery
).
success
(
function
()
{
this
.
sequelize
.
query
(
"select username as "
+
qq
(
"user.username"
)
+
" from "
+
qq
(
this
.
User
.
tableName
)
+
""
)
.
complete
(
function
(
err
,
users
)
{
if
(
err
)
{
console
.
log
(
err
)
}
expect
(
err
).
toBeNull
()
expect
(
users
.
map
(
function
(
u
){
return
u
.
user
})).
toEqual
([{
'username'
:
'john'
}])
done
()
done
()
})
})
}.
bind
(
this
))
}.
bind
(
this
))
...
...
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