Sequelize: Getting "TypeError: Cannot call method 'replace' of null" when using sqlite

Created on 1 Sep 2014  路  3Comments  路  Source: sequelize/sequelize

I'm using the following, protocol-less, code to set up a Sequelize 1.7.10 instance using sqlite3 2.2.7:

var Sequelize = require("sequelize");
var sequelize = new Sequelize("inkcyclopedia", {
      dialect: "sqlite",
      storage: "inkcyclopedia.sqlite"
    });

But running this code generates the following error:

      options.dialect = urlParts.protocol.replace(/:$/, '')
                                          ^
TypeError: Cannot call method 'replace' of null

Which makes sense, because I never specified a protocol, so it defaults to null. Pretty sure this should not cause a problem, as there is no username/password requirement for sqlite files, yet it throws an error.

Most helpful comment

Looks like it's interpreting the database as a connection URI, try doing new Sequelize("inkcyclopedia", null, null, {})

All 3 comments

Looks like it's interpreting the database as a connection URI, try doing new Sequelize("inkcyclopedia", null, null, {})

looks like it; with null username/pass the connection gets set up correctly.

This fix works! Thanks. Might I suggest adding it as an example here in the documentation: http://sequelize.readthedocs.io/en/latest/api/sequelize/ There is no SQLite3 example currently, so this would certainly help things.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kasparsklavins picture kasparsklavins  路  3Comments

couds picture couds  路  3Comments

lfcgomes picture lfcgomes  路  3Comments

hassan-ahmed picture hassan-ahmed  路  3Comments

wmulligan picture wmulligan  路  3Comments