-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[WIP] sqldb: InvoiceDB interface implementation #7357
Closed
positiveblue
wants to merge
9
commits into
lightningnetwork:master
from
positiveblue:invoice-sql-implementation
Closed
[WIP] sqldb: InvoiceDB interface implementation #7357
positiveblue
wants to merge
9
commits into
lightningnetwork:master
from
positiveblue:invoice-sql-implementation
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 tasks
positiveblue
force-pushed
the
invoice-sql-implementation
branch
3 times, most recently
from
June 8, 2023 00:14
7adfde6
to
68fdd28
Compare
positiveblue
force-pushed
the
invoice-sql-implementation
branch
2 times, most recently
from
June 10, 2023 00:12
146daec
to
9474081
Compare
Concept Ack |
Needs rebase. Ready for first look? |
positiveblue
force-pushed
the
invoice-sql-implementation
branch
from
September 22, 2023 19:06
9474081
to
9e3d112
Compare
sqlc has now an official dockerhub organization (sqlc). The old org was the personal dev account, and new images are not uploaded there anymore. It looks like they formed a company (Riza, Inc) and are dedicating 100% of their time to the project (which is great news!) [sqlc v1.21.0](sqlc-dev/sqlc#2709) has a bug generating unvalid go code (files with unused imports) so we use v1.20.0
By default `INTEGER` translates to 64 bits long int in sqlite. For postgres we are translating `INTEGER PRIMARY KEY` to `SERIAL PRIMARY KEY`. The last piece is that we use `uint64` in Go for many identifiers (ex: `AddIndex` in Invoices). Given that SQL does not have uint of any size, we will use `BIGSERIAL PRIMARY KEY` in postgres, `INTEGER PRIMARY KEY` in sqlite and parse it as uint64 in Go. NOTE: sqlite creates a shadow rowid column for each row in a table. If the primary key of that table is defined as `INTEGER PRIMARY KEY` the column will be an alias for the rowid column. That IS NOT the case when we use `BIGINT PRIMARY KEY`, even when both are int64 in sqlite. SQLite does not have autoincrement for BIGINT, so we need to replace it for INTEGER while making sure sqlc uses int64 for that field.
// TODO
Reuse the test suite from the channeldb implementation
The test for this functionality has been updated to make sure that we do not delete settled invoices with this method.
positiveblue
force-pushed
the
invoice-sql-implementation
branch
from
September 25, 2023 16:10
9e3d112
to
59c2e52
Compare
Closing this due to takeover in #8052 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We need to be careful with the zero value of some types that can be null:
[]myType{}
vsvar myVar []myType
by default what I did is if it is nullable and the "empty" value has no meaning do not store it in the db. However, I set it to that value when unmarshaling data from the db.In sqlc, different queries return different types, even if they have the same fields. For example
GetAMPPaymentBySetID
andGetAMPPaymentsByInvoiceIDRow
are not the same type.LookupInvoice
does not load the custom records yet. They will be serialized in a similar way features are.Currently the PR is organized with each commit implementing one of the InvoiceDB interface methods. The commit includes some tests (form the ones in
channeldb/invoices_test.go
) to ensure that we pass the current suite. Before promoting the draft I will split in one method per commit + one commit per functionality test so it is easier to check that we cover all the old functionalities.NOTE: This PR is the 3 out of X PRs for fixing #6288
It builds on top of #7354, relevant commits from
sqldb: implement AddInvoice