-
Notifications
You must be signed in to change notification settings - Fork 285
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
d258799
to
c075729
Compare
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.
c075729
to
779e10e
Compare
There was a problem hiding this 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.
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