dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 376 forks source link

Unsupported field name 'type' #665

Open Bludwarf opened 9 years ago

Bludwarf commented 9 years ago

Hi team,

When using an SQL field nammed "type" and using it as "type" and not "type_id" orm throws the error : TypeError: Cannot read property 'isInstance' of null.

Here is the model definition using Express.

// use "lien.type" instead of "lien.type_id"
db.settings.set("properties.association_key", "{name}");

// lientype
models.lientype = db.define("lientype", {
    name: String
});

// lien
models.lien = db.define("lien", {
    title: String,
    url: String
});
models.lien.hasOne('type', models.lientype);

Thank you for your great work guys.

dxg commented 9 years ago

Where's your definition of the type table?

Bludwarf commented 9 years ago

Hi dxg, There is no type table but only lientype table referenced by lien table. Am I missing something with the syntax ?