dresende / node-orm2

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

.save() does not seem to work with type "object" #767

Closed xorbis closed 7 years ago

xorbis commented 7 years ago

I have a model with a data column set to type "object" type and when I call any of those:

row.data[idx] = "Hello World!";
row.save(cb);
let data = row.data;
data[idx] = "Hello World!";
row.save({data: data}, cb);

No UPDATE call shows up in the debug log.

I had to use a raw query to achieve a single row update. Any clue on what I might be doing wrong? This is a simple model with no relations. All options are on defaults except for debug.

dxg commented 7 years ago

It's a result of dirty tracking; as far as ORM is concerned, the object hasn't changed, so no update is run. Have a look at #517 .

You can solve this by calling:

row.set(['data', idx], "Hello World!")

I believe.. but see #517 for more.

xorbis commented 7 years ago

Thanks much!