dresende/node-orm2 — pull request #222 by TiddoLangerak (2013-07-10 20:15:23+00:00)
Title: Bugfix for optional foreign keys

lib/Instance.js:549 uses 'typeof' to check if opts.data[asc.name] is an object. However, 'typeof null == "object"'. Therefore when opts.data[asc.name] == null the condition on line 549 would evaluate to true and line 550 will throw an error.

This situation occurs at least when an optional FK is defined (postgres) and its value is null. Other situations might trigger this error as well.

This bugfix changes line 549 such that it uses 'instanceof' instead of 'typeof'.