coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Deprecated method called in persistenceStore.getSession() #56

Open lorensr opened 12 years ago

lorensr commented 12 years ago
  p = require('persistencejs/lib/persistence').persistence
  ps = require 'persistencejs/lib/persistence.store.mysql'
  ps.config p, 'localhost', 3306, 'db', 'user', 'pass'
  session = ps.getSession()

gives

Error: deprecated: connect() is now done automatically.
    at Client.connect (/usr/local/lib/node_modules/persistencejs/node_modules/mysql/lib/client.js:40:9)
    at Object.getSession (/usr/local/lib/node_modules/persistencejs/lib/persistence.store.mysql.js:27:10)
    at Object.<anonymous> (eval at <anonymous> (/usr/local/lib/node_modules/zappa/lib/zappa.js:35:12))
    at anonymous (eval at <anonymous> (/usr/local/lib/node_modules/zappa/lib/zappa.js:35:12))
    at /usr/local/lib/node_modules/zappa/lib/zappa.js:640:20
    at callbacks (/usr/local/lib/node_modules/zappa/node_modules/express/lib/router/index.js:272:11)
    at param (/usr/local/lib/node_modules/zappa/node_modules/express/lib/router/index.js:246:11)
    at pass (/usr/local/lib/node_modules/zappa/node_modules/express/lib/router/index.js:253:5)
    at Router._dispatch (/usr/local/lib/node_modules/zappa/node_modules/express/lib/router/index.js:280:4)
    at Object.handle (/usr/local/lib/node_modules/zappa/node_modules/express/lib/router/index.js:45:10)

persistencejs version 0.2.5

ovaillancourt commented 12 years ago

The issue is due to a bad dependency definition on the npm package definition of persistencejs. The package defines the mysql dependeny's version (node-mysql) as larger or equal than 0.7.0, so basically npm currently installs mysql 0.9.4 as the latest version.

node-mysql however added changes in 0.9.2 that break backward compatibility after version 0.9.1, so basically persistencejs is downloading a dependency that breaks the package.

My current workaround is to separately download mysql 0.9.1 and copy/paste it in the persistencejs dependency folder, untill persistencejs is patched for that. (The patch should be relatively easy to produce given the changes made in the mysql module, I don't really have time to do it right now though :/).

joshsmith commented 12 years ago

Hopefully my pull request will squash this issue once and for all.

https://github.com/zefhemel/persistencejs/pull/68