node-firebird icon indicating copy to clipboard operation
node-firebird copied to clipboard

Blob, Sequentially API changes and some bugs

Open sdnetwork opened this issue 9 years ago • 10 comments

BLOB

I have done some works on our provider this week. Initially it was to find a good solution about the blob problem ( #51 #82)

In fact the problem is that a transaction is open each time we read a blob but it's not a good solution (http://tracker.firebirdsql.org/browse/CORE-2086).

so the tip is to use the same transaction to fetch the rows and read the blob, but in the current api we get the rows in the callback after the transaction is finished ! So we need to change some behaviour !

In the api we can separate two kind of method by database object or by transaction object. the solution is to fetch automatically the blob when we use the database object. no change with the transaction.

SEQUENTIALLY

An other thing about the sequentially API, today we can't use it with an other asynchronous api. So i have had a third parameter to the callback like the async library

db.sequentially(query, [params], function(row, index, next) {
  res.write(JSON.stringify(row) + ',');
  next()
}, function(err) {
  res.end(']');
});

i have also add a new method in transaction object => transaction.sequentilally

BUGS

When i have done the change in the provider i have found some problems

  1. in the decoderesponse in fact we can get a false callback if there are several gds error in same time because the lookupMessages is async.
  2. A problem with the pool when there are error on socket.

i have planned to push the changes on my repository https://github.com/sdnetwork/node-firebird, for people want to try the new things and after that i could do a pull request.

ps : these changes can break some code, but the convertion is really easy

  1. if you play with blob with database object, you get directly the blob no need to call the function.
  2. if you use the sequentially api don't forget to call the next method in each row

all comments are welcome

sdnetwork avatar Feb 26 '17 21:02 sdnetwork

It's done, you can check on https://github.com/sdnetwork/node-firebird

sdnetwork avatar Feb 27 '17 20:02 sdnetwork

Yes, @sdnetwork your version all works fine.

There is a possibility to your code be submited to npm?

tfiliano avatar Apr 21 '17 02:04 tfiliano

@tfiliano , i have done a publish on [email protected]

sdnetwork avatar Apr 27 '17 16:04 sdnetwork

How, can I set callback after all records are readed?

DariuszLuber avatar Nov 07 '17 17:11 DariuszLuber

@hgourvest could we get the Blob solution from @sdnetwork implemented? Tried to read blobs from Firebird 3.0 which I could not get to work with the current version. See also #241.

fela98 avatar Feb 01 '21 09:02 fela98

hi @hgourvest and @sdnetwork is there any way to help bring both version together? it seems there are interesting changes in both versions?

@sdnetwork could you create a pr for the transaction/sequentially changes? @hgourvest would you be willing to merge a good pr? how could someone else (like me) help to accomplish this?

thanks sebastian

dotob avatar Jan 23 '23 13:01 dotob

Please I want to kwon too...

https://github.com/hgourvest/node-firebird/issues/273

FabianoCastro avatar Jan 24 '23 02:01 FabianoCastro

would be awesome

Ne0os avatar Jan 24 '23 13:01 Ne0os

hi @hgourvest and @sdnetwork i would be willing to pay 500€ bounty to get a version that has async compatible sequentially functionality. can i motivate someone to pull up his sleeves? ;-)

dotob avatar Feb 03 '23 17:02 dotob

@dotob you can donate for me if you can , i will try to merge it and maybe rewrite the pull request when i have time

https://github.com/sponsors/mariuz

mariuz avatar Mar 03 '23 15:03 mariuz