-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat(binary uuids): implement binary(16) uuids for cash table #152
feat(binary uuids): implement binary(16) uuids for cash table #152
Conversation
@IMA-WorldHealth/local-contributors , what do you think of this method for binary UUIDs? If this is approved, we should quickly change ALL uuids to binary uuids, not just the cash table uuids. |
0025836
to
f8338c5
Compare
'SELECT BUID(cash_uuid) AS uuid FROM cash_discard WHERE cash_uuid = ?;'; | ||
|
||
// parse the uuid into a buffer | ||
const buffer = db.bid(id); |
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.
Why not to have the same name as function, so that we should change the method db.bid(id)
to db.buid(id)
.
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.
One function takes HEX -- > BIN, the other takes BIN --> HEX. I was concerned that people might mix the two up if they had the same name.
If you feel strongly that they should be identically named, I can alter the API.
@jniles |
@DedrickEnc , if there was a performance difference, I couldn't measure it. Since we never write more than a few rows at a time to the database, my guess is that the no user will ever feel a difference -- the difference would be fractions of a millisecond. On read, I noticed slight increase in speed finding random binary UUIDs in a table of 25,000 rows -- but these differences were not statistically significant (too small sample size, too long to run tests). |
a62f3cf
to
cf224bf
Compare
@DedrickEnc, can I get a review? |
07834e7
to
0790a1a
Compare
@DedrickEnc, is preferring |
@jniles |
Okay, we can discuss when everyone's back. I will not change this because:
I am deeply concerned in the number of pull requests that are blocked from comments not related to their:
These pull requests seem to be blocked for silly reasons, usually their choice of names or something similar. For this software to grow, we should learn how to prioritize the functionality over the code style. Particularly when we have not had discussions to say that one style is better than another. I will reopen this pull request when we have a chance to discuss this. |
As we are running out of time I am making the decision to open this pull request and I will evaluate the code. As we are using git to version control our codebase this can be undone if necessary once the team is together. |
This commit implements a proof-of-concept binary UUID storage scheme for the cash module. The integration tests have been updated accordingly. **Overview** The introduction of binary uuids means that a little more work must be done in the controllers and sql to insert/retrieve data. Some commands in Node and SQL have been added to ease this process. I'll document these differences as `before` and `after` scenarios. READ Before: ```sql SELECT uuid FROM table; ``` After: ```sql SELECT BUID(uuid) AS uuid FROM table; ``` **Note**: it is important to alias the column with `AS` in order to preserve the property name `uuid`. The command `BUID()` has been added to our MySQL database instance to convert binary uuids into hexadecimal uuids. WRITE Before: ```js var insertSql = 'INSERT INTO table SET ?;'; var updateSql = 'UPDATE table SET ? WHERE uuid = ?;'; var data = { uuid : /** some uuid */, /* other properties ... */ }; db.exec(insertSql, [ data ]).then(/* ... */).catch(/* .. */); db.exec(updateSql, [ data, req.params.uuid ]).then(/* ... */).catch(/* .. */); ``` After: ```js var insertSql = 'INSERT INTO table SET ?;'; var updateSql = 'UPDATE table SET ? WHERE uuid = ?;'; var data = { uuid : /** some uuid */, /* other properties ... */ }; // convert the hex uuid into a binary uuid data.uuid = db.bid(data.uuid); // insert with the new data db.exec(insertSql, [ data ]).then(/* ... */).catch(/* .. */); db.exec(updateSql, [ data, db.bid(req.params.uuid) ]).then(/* ... */).catch(/* .. */); ``` I'd be curious if we can come up with a better API for binary conversions. The currenct method is pragmatic, but possibly unclear.
0790a1a
to
c9d3f5b
Compare
@sfount, updated to latest master. |
@@ -35,25 +35,29 @@ exports.debitNote = debitNote; | |||
|
|||
// looks up a single cash record and associated cash_items | |||
// sets the "canceled" flag if a cash_discard record exists. | |||
function lookupCashRecord(uuid, codes) { | |||
function lookupCashRecord(id, codes) { |
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.
Just a note that this should be updated given #182. This is not directly related to the pull request and will not block it.
This should be addressed in the Cash 2.x Review.
To conclude the discussion in this thread before I close this; the team will discuss the use of newly introduced JavaScript features when they return from Tshikaji. Right now we are not in a position (both with geographical differences and time constraints) to have everything fully worked out before integration. As everything in this pull request is supported in the controlled nodejs environment that we support I am confident that this code will work and pass all of the tests. If the team overrules this from a maintainability standpoint the code can be updated. |
* feat(inventory): nicer inventory price list print This commit improves the inventory item printed report by grouping by inventory group and only showing part of the information as needed. * fix(i18n): translate report title
This commit implements a proof-of-concept binary UUID storage scheme for
the cash module. The integration tests have been updated accordingly.
Overview
The introduction of binary uuids means that a little more work must be
done in the controllers and sql to insert/retrieve data. Some commands
in Node and SQL have been added to ease this process. I'll document
these differences as
before
andafter
scenarios.READ
Before:
After:
Note: it is important to alias the column with
AS
in order topreserve the property name
uuid
. The commandBUID()
has been addedto our MySQL database instance to convert binary uuids into hexadecimal
uuids.
WRITE
Before:
After:
I'd be curious if we can come up with a better API for binary
conversions. The current method is pragmatic, but possibly unclear.
First implementation of #64.