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 95df903a
authored
May 16, 2013
by
reedog117
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress: currently debugging
1 parent
c7fb0217
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
212 additions
and
114 deletions
lib/dialects/mariadb/connector-manager.js
lib/dialects/mariadb/query-generator.js
lib/dialects/mariadb/query.js
package.json
spec/config/config.js
spec/dao-factory.spec.js
spec/sequelize.spec.js
lib/dialects/mariadb/connector-manager.js
View file @
95df903
...
...
@@ -108,7 +108,7 @@ module.exports = (function() {
}
else
if
(
this
.
poolCfg
)
{
//the user has requested pooling, so create our connection pool
this
.
pool
=
Pooling
.
Pool
({
name
:
'sequelize-maria
sql
'
,
name
:
'sequelize-maria
db
'
,
create
:
function
(
done
)
{
connect
.
call
(
self
,
done
)
},
...
...
@@ -207,33 +207,48 @@ module.exports = (function() {
var
disconnect
=
function
(
client
)
{
var
self
=
this
;
if
(
!
this
.
useQueue
)
{
client
.
on
(
'close'
,
function
()
{
self
.
client
=
null
self
.
isConnecting
=
false
})
client
.
end
()
/* if (!this.useQueue) {
this.client = null;
}
*/
client
.
end
(
function
()
{
if
(
!
self
.
useQueue
)
{
return
client
.
destroy
();
}
// moved outside of anon function
var
intervalObj
=
null
var
cleanup
=
function
()
{
var
retryCt
=
0
// make sure to let client finish before calling destroy
if
(
self
&&
self
.
hasQueuedItems
)
{
return
}
// needed to prevent mariasql connection leak
client
.
destroy
()
if
(
self
&&
self
.
client
)
{
self
.
client
=
null
}
clearInterval
(
intervalObj
)
/* if (!self.useQueue && client.connected) {
return client.destroy()
} else {
client.end()
}
var intervalObj = null
var cleanup = function () {
var retryCt = 0
// make sure to let client finish before calling destroy
if (self && self.hasQueuedItems) {
return
}
// needed to prevent mariasql connection leak
// client.destroy()
if (self && self.client) {
self.client = null
}
clearInterval(intervalObj)
}
if(client.connected) {
intervalObj = setInterval(cleanup, 10)
cleanup()
return
})
}*/
return
}
var
connect
=
function
(
done
,
config
)
{
...
...
@@ -295,6 +310,10 @@ module.exports = (function() {
}
var
transferQueuedItems
=
function
(
count
)
{
// prevent possible overrun condition
if
(
count
>
this
.
queue
.
length
)
count
=
this
.
queue
.
length
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
var
queueItem
=
this
.
queue
.
shift
();
if
(
queueItem
)
{
...
...
@@ -332,7 +351,7 @@ module.exports = (function() {
})
ConnectorManager
.
prototype
.
__defineGetter__
(
'isConnected'
,
function
()
{
return
this
.
client
!=
null
return
this
.
client
!=
null
&&
this
.
client
.
connected
==
true
})
var
disconnectIfNoConnections
=
function
()
{
...
...
lib/dialects/mariadb/query-generator.js
View file @
95df903
...
...
@@ -45,6 +45,7 @@ module.exports = (function() {
var
query
=
"CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>) ENGINE=<%= engine %> <%= charset %>"
,
primaryKeys
=
[]
,
foreignKeys
=
{}
,
attrStr
=
[]
for
(
var
attr
in
attributes
)
{
...
...
@@ -54,6 +55,11 @@ module.exports = (function() {
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
))
{
primaryKeys
.
push
(
attr
)
attrStr
.
push
(
QueryGenerator
.
addQuotes
(
attr
)
+
" "
+
dataType
.
replace
(
/PRIMARY KEY/
,
''
))
}
else
if
(
Utils
.
_
.
includes
(
dataType
,
'REFERENCES'
))
{
// MySQL doesn't support inline REFERENCES declarations: move to the end
var
m
=
dataType
.
match
(
/^
(
.+
)
(
REFERENCES.*
)
$/
)
attrStr
.
push
(
QueryGenerator
.
addQuotes
(
attr
)
+
" "
+
m
[
1
])
foreignKeys
[
attr
]
=
m
[
2
]
}
else
{
attrStr
.
push
(
QueryGenerator
.
addQuotes
(
attr
)
+
" "
+
dataType
)
}
...
...
@@ -72,6 +78,12 @@ module.exports = (function() {
values
.
attributes
+=
", PRIMARY KEY ("
+
pkString
+
")"
}
for
(
var
fkey
in
foreignKeys
)
{
if
(
foreignKeys
.
hasOwnProperty
(
fkey
))
{
values
.
attributes
+=
", FOREIGN KEY ("
+
QueryGenerator
.
addQuotes
(
fkey
)
+
") "
+
foreignKeys
[
fkey
]
}
}
return
Utils
.
_
.
template
(
query
)(
values
).
trim
()
+
";"
},
...
...
@@ -149,8 +161,8 @@ module.exports = (function() {
},
selectQuery
:
function
(
tableName
,
options
)
{
var
query
=
"SELECT <%= attributes %> FROM <%= table %>"
,
table
=
null
var
table
=
null
,
joinQuery
=
""
options
=
options
||
{}
options
.
table
=
table
=
Array
.
isArray
(
tableName
)
?
tableName
.
map
(
function
(
tbl
){
return
QueryGenerator
.
addQuotes
(
tbl
)
}).
join
(
", "
)
:
QueryGenerator
.
addQuotes
(
tableName
)
...
...
@@ -168,75 +180,92 @@ module.exports = (function() {
options
.
include
.
forEach
(
function
(
include
)
{
var
attributes
=
Object
.
keys
(
include
.
daoFactory
.
attributes
).
map
(
function
(
attr
)
{
var
template
=
Utils
.
_
.
template
(
"`<%= as %>`.`<%= attr %>` AS `<%= as %>.<%= attr %>`"
)
return
template
({
as
:
include
.
as
,
attr
:
attr
})
return
"`"
+
include
.
as
+
"`.`"
+
attr
+
"` AS `"
+
include
.
as
+
"."
+
attr
+
"`"
})
optAttributes
=
optAttributes
.
concat
(
attributes
)
var
joinQuery
=
" LEFT OUTER JOIN `<%= table %>` AS `<%= as %>` ON `<%= tableLeft %>`.`<%= attrLeft %>` = `<%= tableRight %>`.`<%= attrRight %>`"
query
+=
Utils
.
_
.
template
(
joinQuery
)({
table
:
include
.
daoFactory
.
tableName
,
as
:
include
.
as
,
tableLeft
:
((
include
.
association
.
associationType
===
'BelongsTo'
)
?
include
.
as
:
tableName
),
attrLeft
:
'id'
,
tableRight
:
((
include
.
association
.
associationType
===
'BelongsTo'
)
?
tableName
:
include
.
as
),
attrRight
:
include
.
association
.
identifier
})
var
table
=
include
.
daoFactory
.
tableName
var
as
=
include
.
as
var
tableLeft
=
((
include
.
association
.
associationType
===
'BelongsTo'
)
?
include
.
as
:
tableName
)
var
attrLeft
=
'id'
var
tableRight
=
((
include
.
association
.
associationType
===
'BelongsTo'
)
?
tableName
:
include
.
as
)
var
attrRight
=
include
.
association
.
identifier
joinQuery
+=
" LEFT OUTER JOIN `"
+
table
+
"` AS `"
+
as
+
"` ON `"
+
tableLeft
+
"`.`"
+
attrLeft
+
"` = `"
+
tableRight
+
"`.`"
+
attrRight
+
"`"
})
options
.
attributes
=
optAttributes
.
join
(
', '
)
}
if
(
options
.
where
)
{
var
query
=
"SELECT "
+
options
.
attributes
+
" FROM "
+
options
.
table
query
+=
joinQuery
if
(
options
.
hasOwnProperty
(
'where'
))
{
options
.
where
=
this
.
getWhereConditions
(
options
.
where
,
tableName
)
query
+=
" WHERE
<%= where %>"
query
+=
" WHERE
"
+
options
.
where
}
if
(
options
.
group
)
{
options
.
group
=
Array
.
isArray
(
options
.
group
)
?
options
.
group
.
map
(
function
(
grp
){
return
QueryGenerator
.
addQuotes
(
grp
)}).
join
(
', '
)
:
QueryGenerator
.
addQuotes
(
options
.
group
)
query
+=
" GROUP BY
<%= group %>"
query
+=
" GROUP BY
"
+
options
.
group
}
if
(
options
.
order
)
{
query
+=
" ORDER BY
<%= order %>"
query
+=
" ORDER BY
"
+
options
.
order
}
if
(
options
.
limit
&&
!
(
options
.
include
&&
(
options
.
limit
===
1
)))
{
if
(
options
.
offset
)
{
query
+=
" LIMIT
<%= offset %>, <%= limit %>"
query
+=
" LIMIT
"
+
options
.
offset
+
", "
+
options
.
limit
}
else
{
query
+=
" LIMIT
<%= limit %>"
query
+=
" LIMIT
"
+
options
.
limit
}
}
query
+=
";"
return
Utils
.
_
.
template
(
query
)(
options
)
return
query
},
insertQuery
:
function
(
tableName
,
attrValueHash
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>);"
var
replacements
=
{
table
:
QueryGenerator
.
addQuotes
(
tableName
),
attributes
:
Object
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
QueryGenerator
.
addQuotes
(
attr
)}).
join
(
","
),
values
:
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
attributes
=
Object
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
QueryGenerator
.
addQuotes
(
attr
)}).
join
(
","
)
var
values
=
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
Utils
.
escape
((
value
instanceof
Date
)
?
Utils
.
toSqlDate
(
value
)
:
value
)
}).
join
(
","
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
var
query
=
"INSERT INTO "
+
table
+
" ("
+
attributes
+
") VALUES ("
+
values
+
");"
return
query
},
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
)
{
var
tuples
=
[]
Utils
.
_
.
forEach
(
attrValueHashes
,
function
(
attrValueHash
)
{
tuples
.
push
(
"("
+
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
Utils
.
escape
((
value
instanceof
Date
)
?
Utils
.
toSqlDate
(
value
)
:
value
)
}).
join
(
","
)
+
")"
)
})
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
attributes
=
Object
.
keys
(
attrValueHashes
[
0
]).
map
(
function
(
attr
){
return
QueryGenerator
.
addQuotes
(
attr
)}).
join
(
","
)
var
query
=
"INSERT INTO "
+
table
+
" ("
+
attributes
+
") VALUES "
+
tuples
.
join
(
","
)
+
";"
return
query
},
updateQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"UPDATE <%= table %> SET <%= values %> WHERE <%= where %>;"
,
values
=
[]
var
values
=
[]
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
...
...
@@ -245,34 +274,48 @@ module.exports = (function() {
values
.
push
(
QueryGenerator
.
addQuotes
(
key
)
+
"="
+
Utils
.
escape
(
_value
))
}
var
replacements
=
{
table
:
QueryGenerator
.
addQuotes
(
tableName
),
values
:
values
.
join
(
","
),
where
:
QueryGenerator
.
getWhereConditions
(
where
)
}
var
query
=
"UPDATE "
+
QueryGenerator
.
addQuotes
(
tableName
)
+
" SET "
+
values
.
join
(
","
)
+
" WHERE "
+
QueryGenerator
.
getWhereConditions
(
where
)
return
Utils
.
_
.
template
(
query
)(
replacements
)
return
query
},
deleteQuery
:
function
(
tableName
,
where
,
options
)
{
options
=
options
||
{}
options
.
limit
=
options
.
limit
||
1
var
query
=
"DELETE FROM <%= table %> WHERE <%= where %> LIMIT <%= limit %>;"
var
replacements
=
{
table
:
QueryGenerator
.
addQuotes
(
tableName
),
where
:
QueryGenerator
.
getWhereConditions
(
where
),
limit
:
Utils
.
escape
(
options
.
limit
)
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
where
=
QueryGenerator
.
getWhereConditions
(
where
)
var
limit
=
""
if
(
Utils
.
_
.
isUndefined
(
options
.
limit
))
{
options
.
limit
=
1
;
}
if
(
!!
options
.
limit
)
{
limit
=
" LIMIT "
+
Utils
.
escape
(
options
.
limit
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
var
query
=
"DELETE FROM "
+
table
+
" WHERE "
+
where
+
limit
return
query
},
bulkDeleteQuery
:
function
(
tableName
,
where
,
options
)
{
options
=
options
||
{}
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
where
=
QueryGenerator
.
getWhereConditions
(
where
)
var
query
=
"DELETE FROM "
+
table
+
" WHERE "
+
where
return
query
},
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"UPDATE <%= table %> SET <%= values %> WHERE <%= where %> ;"
,
values
=
[]
var
values
=
[]
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
...
...
@@ -281,13 +324,13 @@ module.exports = (function() {
values
.
push
(
QueryGenerator
.
addQuotes
(
key
)
+
"="
+
QueryGenerator
.
addQuotes
(
key
)
+
" + "
+
Utils
.
escape
(
_value
))
}
var
replacements
=
{
table
:
QueryGenerator
.
addQuotes
(
tableName
),
values
:
values
.
join
(
","
),
where
:
QueryGenerator
.
getWhereConditions
(
where
)
}
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
values
=
values
.
join
(
","
)
var
where
=
QueryGenerator
.
getWhereConditions
(
where
)
var
query
=
"UPDATE "
+
table
+
" SET "
+
values
+
" WHERE "
+
where
return
Utils
.
_
.
template
(
query
)(
replacements
)
return
query
},
addIndexQuery
:
function
(
tableName
,
attributes
,
options
)
{
...
...
@@ -355,23 +398,14 @@ module.exports = (function() {
getWhereConditions
:
function
(
smth
,
tableName
)
{
var
result
=
null
function
isNumeric
(
n
)
{
return
!
isNaN
(
parseFloat
(
n
))
&&
isFinite
(
n
);
}
if
(
Utils
.
isHash
(
smth
))
{
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
smth
)
result
=
this
.
hashToWhereConditions
(
smth
)
}
else
if
(
typeof
smth
===
'number'
)
{
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
{
'id'
:
smth
})
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
{
id
:
smth
})
result
=
this
.
hashToWhereConditions
(
smth
)
}
else
if
(
typeof
smth
===
"string"
)
{
if
(
!
isNumeric
(
smth
))
{
result
=
smth
}
else
{
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
{
'id'
:
smth
})
result
=
this
.
hashToWhereConditions
(
smth
)
}
result
=
smth
}
else
if
(
Array
.
isArray
(
smth
))
{
result
=
Utils
.
format
(
smth
)
}
...
...
@@ -419,17 +453,18 @@ module.exports = (function() {
var
dataType
=
attributes
[
name
]
if
(
Utils
.
isHash
(
dataType
))
{
var
template
=
"<%= type %>"
,
replacements
=
{
type
:
dataType
.
type
}
var
template
if
(
dataType
.
type
.
toString
()
===
DataTypes
.
ENUM
.
toString
())
{
if
(
Array
.
isArray
(
dataType
.
values
)
&&
(
dataType
.
values
.
length
>
0
))
{
replacements
.
typ
e
=
"ENUM("
+
Utils
.
_
.
map
(
dataType
.
values
,
function
(
value
)
{
templat
e
=
"ENUM("
+
Utils
.
_
.
map
(
dataType
.
values
,
function
(
value
)
{
return
Utils
.
escape
(
value
)
}).
join
(
", "
)
+
")"
}
else
{
throw
new
Error
(
'Values for ENUM haven\'t been defined.'
)
}
}
else
{
template
=
dataType
.
type
.
toString
();
}
if
(
dataType
.
hasOwnProperty
(
'allowNull'
)
&&
(
!
dataType
.
allowNull
))
{
...
...
@@ -441,8 +476,7 @@ module.exports = (function() {
}
if
((
dataType
.
defaultValue
!=
undefined
)
&&
(
dataType
.
defaultValue
!=
DataTypes
.
NOW
))
{
template
+=
" DEFAULT <%= defaultValue %>"
replacements
.
defaultValue
=
Utils
.
escape
(
dataType
.
defaultValue
)
template
+=
" DEFAULT "
+
Utils
.
escape
(
dataType
.
defaultValue
)
}
if
(
dataType
.
unique
)
{
...
...
@@ -453,7 +487,27 @@ module.exports = (function() {
template
+=
" PRIMARY KEY"
}
result
[
name
]
=
Utils
.
_
.
template
(
template
)(
replacements
)
if
(
dataType
.
references
)
{
template
+=
" REFERENCES "
+
Utils
.
addTicks
(
dataType
.
references
)
if
(
dataType
.
referencesKey
)
{
template
+=
" ("
+
Utils
.
addTicks
(
dataType
.
referencesKey
)
+
")"
}
else
{
template
+=
" ("
+
Utils
.
addTicks
(
'id'
)
+
")"
}
if
(
dataType
.
onDelete
)
{
template
+=
" ON DELETE "
+
dataType
.
onDelete
.
toUpperCase
()
}
if
(
dataType
.
onUpdate
)
{
template
+=
" ON UPDATE "
+
dataType
.
onUpdate
.
toUpperCase
()
}
}
result
[
name
]
=
template
}
else
{
result
[
name
]
=
dataType
}
...
...
lib/dialects/mariadb/query.js
View file @
95df903
...
...
@@ -23,30 +23,53 @@ module.exports = (function() {
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
}
var
resultSet
=
[];
var
query
=
this
.
client
.
query
(
this
.
sql
),
resultSet
=
[],
errorDetected
=
false
,
temp
=
1
this
.
client
.
query
(
this
.
sql
)
.
on
(
'result'
,
function
(
results
)
{
results
.
on
(
'row'
,
function
(
row
)
{
resultSet
.
push
(
row
);
})
.
on
(
'error'
,
function
(
err
)
{
this
.
emit
(
'error'
,
err
,
this
.
callee
)
})
.
on
(
'end'
,
function
(
info
)
{
//console.log(info)
});
query
.
on
(
'result'
,
function
(
results
)
{
var
resultStream
=
results
;
results
.
on
(
'row'
,
function
(
row
)
{
resultSet
.
push
(
row
);
})
.
on
(
'error'
,
function
(
err
)
{
//console.log('error in result-loop for: ' + self.sql)
errorDetected
=
true
this
.
emit
(
'sql'
,
this
.
sql
)
console
.
log
(
'Failed query : '
+
this
.
sql
)
console
.
log
(
err
)
resultStream
.
abort
()
this
.
emit
(
'error'
,
err
,
this
.
callee
)
}.
bind
(
this
))
.
on
(
'end'
,
function
(
info
)
{
//console.log(info)
if
(
errorDetected
)
return
//this.emit('sql', this.sql)
//this.emit('success', this.formatResults(resultSet))
}.
bind
(
this
));
}.
bind
(
this
))
.
on
(
'error'
,
function
(
err
)
{
console
.
log
(
stack
)
//this.emit('error', err, this.callee)
})
//console.log( err )
//console.log('error in query: ' + this.sql)
// if(errorDetected)
// return
// errorDetected = true
// this.emit('sql', this.sql)
// this.emit('error', err, this.callee)
console
.
log
(
'query error'
)
}.
bind
(
this
))
.
on
(
'end'
,
function
()
{
if
(
errorDetected
)
return
this
.
emit
(
'sql'
,
this
.
sql
)
console
.
log
(
'Successful query : '
+
this
.
sql
)
console
.
log
(
resultSet
)
this
.
emit
(
'success'
,
this
.
formatResults
(
resultSet
))
}.
bind
(
this
))
}.
bind
(
this
)).
setMaxListeners
(
100
)
return
this
}
...
...
package.json
View file @
95df903
...
...
@@ -35,7 +35,7 @@
"validator"
:
"1.1.1"
,
"moment"
:
"~1.7.0"
,
"commander"
:
"~0.6.0"
,
"generic-pool"
:
"1.0.
9
"
,
"generic-pool"
:
"1.0.
12
"
,
"dottie"
:
"0.0.6-1"
,
"toposort-class"
:
"0.1.4"
},
...
...
@@ -47,8 +47,7 @@
"mariasql"
:
"~0.1.18"
,
"buster"
:
"~0.6.0"
,
"watchr"
:
"~2.2.0"
,
"yuidocjs"
:
"~0.3.36"
,
"mariasql"
:
"~0.1.18"
"yuidocjs"
:
"~0.3.36"
},
"keywords"
:
[
"mysql"
,
...
...
spec/config/config.js
View file @
95df903
...
...
@@ -25,7 +25,7 @@ module.exports = {
database
:
'sequelize_test'
,
host
:
'127.0.0.1'
,
port
:
3306
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
pool
:
{
maxConnections
:
1
,
maxIdleTime
:
30
}
},
sqlite
:
{
...
...
spec/dao-factory.spec.js
View file @
95df903
...
...
@@ -168,6 +168,7 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
Helpers
.
checkMatchForDialects
(
dialect
,
err
.
message
,
{
sqlite
:
/.*SQLITE_CONSTRAINT.*/
,
mysql
:
/.*Duplicate
\
entry.*/
,
mariadb
:
/.*Duplicate
\
entry.*/
,
postgres
:
/.*duplicate
\
key
\
value.*/
})
...
...
@@ -190,6 +191,7 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
Helpers
.
checkMatchForDialects
(
dialect
,
err
.
message
,
{
sqlite
:
/.*SQLITE_CONSTRAINT.*/
,
mysql
:
"Column 'smth' cannot be null"
,
mariadb
:
"Column 'smth' cannot be null"
,
postgres
:
/.*column "smth" violates not-null.*/
})
...
...
@@ -200,6 +202,7 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
Helpers
.
checkMatchForDialects
(
dialect
,
err
.
message
,
{
sqlite
:
/.*SQLITE_CONSTRAINT.*/
,
mysql
:
"Duplicate entry 'foo' for key 'username'"
,
mariadb
:
"Duplicate entry 'foo' for key 'username'"
,
postgres
:
/.*duplicate key value violates unique constraint.*/
})
...
...
@@ -1499,7 +1502,7 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
if
(
dialect
===
"mysql"
)
{
if
(
dialect
===
"mysql"
/* || dialect === "mariadb" */
)
{
it
(
"should take schemaDelimiter into account if applicable"
,
function
(
done
){
var
UserSpecialUnderscore
=
this
.
sequelize
.
define
(
'UserSpecialUnderscore'
,
{
age
:
Sequelize
.
INTEGER
},
{
schema
:
'hello'
,
schemaDelimiter
:
'_'
})
var
UserSpecialDblUnderscore
=
this
.
sequelize
.
define
(
'UserSpecialDblUnderscore'
,
{
age
:
Sequelize
.
INTEGER
})
...
...
spec/sequelize.spec.js
View file @
95df903
...
...
@@ -7,7 +7,7 @@ if(typeof require === 'function') {
var
qq
=
function
(
str
)
{
if
(
dialect
==
'postgres'
||
dialect
==
'sqlite'
)
{
return
'"'
+
str
+
'"'
}
else
if
(
dialect
==
'mysql'
)
{
}
else
if
(
dialect
==
'mysql'
||
dialect
==
'mariadb'
)
{
return
'`'
+
str
+
'`'
}
else
{
return
str
...
...
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