biggora / caminte

Cross-db ORM for NodeJS
http://www.camintejs.com/
MIT License
1.08k stars 119 forks source link

Problem with id column even when defining a primary key on model. #85

Open guilhermeKodama opened 8 years ago

guilhermeKodama commented 8 years ago

In postgresql i seemed to be forced to create an id column in my table, setting the primaryKeys is not functioning. If i comment the this line on /adapters/postgres.js //sql += ' RETURNING id'; it seems to work , but for delete and others actions this problems repeats.

apmeena commented 8 years ago

I am facing the same problem with Mysql. Anyone have any solution please?

darvydas commented 7 years ago

I had the same issue with MySQL -> save.

Insert starts working only if you declare a primary key on a Schema Model. For example:

// (not working) inserting new item creates an "id" column in a field list and fails
var KonGroup = schema.define('kon_group', {
         kgr_id: { type: schema.Number, limit: 10 },
         del_date: { type: schema.Date }
    },{  });
// (working) inserting increases auto increment value of kgr_id and succeeds
var KonGroup = schema.define('kon_group', {
         kgr_id: { type: schema.Number, limit: 10 },
         del_date: { type: schema.Date }
    },{
         primaryKeys: ['kgr_id']
    });
D3coded commented 7 years ago

I've got the same problem with firebird. But i cannot undergo this by defining primary keys.

PlanungsPosition = schema.define('TPLANUNG_POS', {
  TAG:  { type: schema.Number },
  MONAT:  { type: schema.Number },
  JAHR:  { type: schema.Number },
  MANR:  { type: schema.Number},
  KOMMISSIONSNR:  { type: schema.String },
  AUFTRAG:  { type: schema.String },
  SFK:  { type: schema.String },
  BEAUFTRAGT:  { type: schema.Number }
},{
  primaryKeys: ['TAG', 'MONAT', 'JAHR', 'MANR', 'KOMMISSIONSNR', 'AUFTRAG']
});

What could be the problem there? When i try to call

PlanungsPosition.create( ... )

i get following error:

Error: Dynamic SQL Error, SQL error code = -206, Column unknown, id, At line 1, column 128