不要怂,就是干,撸起袖子干!

Commit 608f4774 by Mick Hansen

Don't fail on sqlite connection uris without a missing trailing slash

1 parent e528ac6c
Showing with 15 additions and 1 deletions
...@@ -56,7 +56,12 @@ module.exports = (function() { ...@@ -56,7 +56,12 @@ module.exports = (function() {
if (arguments.length === 1 || (arguments.length === 2 && typeof username === 'object')) { if (arguments.length === 1 || (arguments.length === 2 && typeof username === 'object')) {
options = username || {} options = username || {}
urlParts = url.parse(arguments[0]) urlParts = url.parse(arguments[0])
database = urlParts.path.replace(/^\//, '')
// SQLite don't have DB in connection url
if (urlParts.path) {
database = urlParts.path.replace(/^\//, '')
}
dialect = urlParts.protocol dialect = urlParts.protocol
options.dialect = urlParts.protocol.replace(/:$/, '') options.dialect = urlParts.protocol.replace(/:$/, '')
options.host = urlParts.hostname options.host = urlParts.hostname
......
...@@ -40,6 +40,15 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -40,6 +40,15 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
expect(sequelize.config.host).to.equal('127.0.0.1') expect(sequelize.config.host).to.equal('127.0.0.1')
done() done()
}) })
if (dialect === 'sqlite') {
it('should work with connection strings (1)', function () {
var sequelize = new Sequelize('sqlite://test.sqlite')
})
it('should work with connection strings (2)', function () {
var sequelize = new Sequelize('sqlite://test.sqlite/')
})
}
}) })
if (dialect !== 'sqlite') { if (dialect !== 'sqlite') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!