DeleteResult / UpdateResult not implemented for all Drivers
Issue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.7 (or put your version here)
Steps to reproduce or a small repository showing the problem:
- invoke
Repository.delete - the returned
DeleteResultdoes not include any info at all. Expecting to include the number of affected rows.
I'm having trouble with Repository.delete: the operation successfully removes the entity from the database, but DeleteResult does not contain count of entities deleted, it's just DeleteResult { raw: [] }. This occurs with v0.2.7.
Also, there doesn't appear to be a tag for version 0.2.7 on GitHub though there's a release on npmjs. Why is that?
Why doesn't DeleteResult specify a property for the number of rows affected?
Also, there doesn't appear to be a tag for version 0.2.7 on GitHub though there's a release on npmjs. Why is that?
I'll fix that.
Why doesn't DeleteResult specify a property for the number of rows affected?
because it wasn't implemented. We already have this feature reported, but noone still took on its implementation. Please feel free, its an easy feature to implement.
@pleerock Can you give a reference to an earlier report? I just tried, but was unable to find one.
I could find only #1308 which is related, need to search deeper to find that one. But anyway, you don't need that issue if you want to implement it. You know what your goal, you can easily do that. But please be sure to implement it for all drivers if you are going to do it. That's easy feature to implement
@pleerock Currently the behavior is different between Postgres and MySQL, for example.
MySQL returns: {"raw":{"fieldCount":0,"affectedRows":0,"insertId":0,"serverStatus":34,"warningCount":0,"message":"","protocol41":true,"changedRows":0}}
Postgres returns: {"raw": []}
So in a sense it seems MySQL already has this feature implemented but not Postgres.
I have the same problem with SQLite and 0.2.8
It returns : {"raw": []}
raw is just raw result returned by underlying database driver. As I pointed above we need to implement this feature request.
MongoDb does not return anything, neither raw nor affected regardless if the record is found/deleted or not.
In case it helps anyone else in the future, for postgres I ended up just using
await this.db.createQueryBuilder()
.delete()
.whereInIds(id)
.returning("id")
.execute();
It returns a DeleteResult like: { raw: [ {id: 1} ], affected: 1 }. You could also do .returning("*") if you want the full object returned.
Is this implemented? I'm facing this issue too with sqlite3 and typeorm@^0.2.12
await this.db.createQueryBuilder() .delete() .whereInIds(id) .returning("id") .execute();
this didn't work for me, it just returns an empty object. I use [email protected].
MongoDb does not return anything, neither raw nor affected regardless if the record is found/deleted or not.
Has it been fixed?
Issue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ]
cordova[ ]mongodb[ ]mssql[ ]mysql/mariadb[ ]oracle[x]postgres[ ]sqlite[ ]sqljs[ ]react-nativeTypeORM version:
[ ]
latest[ ]@next[x]0.2.7(or put your version here)Steps to reproduce or a small repository showing the problem:
- invoke
Repository.delete- the returned
DeleteResultdoes not include any info at all. Expecting to include the number of affected rows.I'm having trouble with
Repository.delete: the operation successfully removes the entity from the database, butDeleteResultdoes not contain count of entities deleted, it's justDeleteResult { raw: [] }. This occurs with v0.2.7.Also, there doesn't appear to be a tag for version 0.2.7 on GitHub though there's a release on npmjs. Why is that?
Why doesn't
DeleteResultspecify a property for the number of rows affected?
same issue for me. any solution..
Same issue. Deleting record in MongoDB results an empty DeleteResult object
Trying to change from sequelize... and i hit this "bug", quite sad this issue is still open..
@AndreySavenkov Same here. I'm curious, how did you managed that then ?
Is there any alternative solution for this?
Same issue. Deleting record in MongoDB results an empty DeleteResult object
Same issue
sqlite
MongoDb does not return anything, neither raw nor affected regardless if the record is found/deleted or not.
Has it been fixed?
+1
@imnotjames can you also add driver:mongodb (or should we open another issue ?)
Same issue in mssql driver