Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core-database-postgres): convert BYTEA to/from string #3058

Merged
merged 4 commits into from
Oct 14, 2019

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Oct 11, 2019

Engage pg-promise's ability to modify the values retrieved from the
database on the fly (the cb argument of
https://vitaly-t.github.io/pg-promise/Database.html#result).

This way we convert transparently the vendorField column which comes as
a Buffer from the database to an UTF8 string. In the other direction,
when inserting into the database, the string is converted to a Buffer
using the init property of the column definition.

Rename findMany and findManyWithCount to findAny and findAnyWithCount.
pg-promise has a method many() which throws if no rows are returned. It
also has a method any() which accepts 0, 1 or more rows as a result
(same as manyOrNone() or result()). Our findMany* methods do
not call the many() method but rather accept any number of rows as a
result.

Summary

Checklist

  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

@codecov
Copy link

codecov bot commented Oct 11, 2019

Codecov Report

Merging #3058 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3058      +/-   ##
===========================================
+ Coverage    65.62%   65.62%   +<.01%     
===========================================
  Files          425      425              
  Lines        11733    11734       +1     
  Branches      1601     1602       +1     
===========================================
+ Hits          7700     7701       +1     
  Misses        3997     3997              
  Partials        36       36
Impacted Files Coverage Δ
...s/core-database-postgres/src/models/transaction.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a3c9d0...b26dbb4. Read the comment docs.

@vasild vasild force-pushed the bytea-to-from-string branch 2 times, most recently from d258799 to c075729 Compare October 11, 2019 15:11
Engage pg-promise's ability to modify the values retrieved from the
database on the fly (the cb argument of
https://vitaly-t.github.io/pg-promise/Database.html#result).

This way we convert transparently the vendorField column which comes as
a Buffer from the database to an UTF8 string. In the other direction,
when inserting into the database, the string is converted to a Buffer
using the init property of the column definition.

Rename findMany and findManyWithCount to findAny and findAnyWithCount.
pg-promise has a method many() which throws if no rows are returned. It
also has a method any() which accepts 0, 1 or more rows as a result
(same as manyOrNone() or result()). Our findMany* methods do
not call the many() method but rather accept any number of rows as a
result.
@vasild vasild force-pushed the bytea-to-from-string branch from c075729 to 779e10e Compare October 11, 2019 15:52
Copy link
Contributor

@spkjp spkjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the to string conversion, so please remove it. One-way is sufficient since the column is technically only needed by core-api for searching.

…o-from-string

* ArkEcosystem/core/develop:
  fix(crypto): handle mainnet address exceptions (#3055)
Remove handling of vendorField (BYTEA) when reading from DB (converting
from Buffer to UTF8 string transparently).

Suggested by: @Supaiku
@spkjp spkjp merged commit 925f052 into develop Oct 14, 2019
@ghost ghost deleted the bytea-to-from-string branch October 14, 2019 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants