-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add query execution utilities #18
Conversation
13775df
to
9cfb220
Compare
cfb45a9
to
7f3095c
Compare
474ff25
to
3e9722f
Compare
7f3095c
to
89805fa
Compare
database/contracts.go
Outdated
// TxOrDB is just a helper interface that can represent a *[sqlx.Tx] or *[DB] instance. | ||
type TxOrDB interface { | ||
sqlx.ExtContext | ||
sqlx.PreparerContext | ||
|
||
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error) | ||
} |
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.
Also the whole thing seems just a subset of DB&Tx. I personally would unexport and move it...
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.
Wouldn't you also want to use this interface type elsewhere where a DB
or Tx
is required?
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.
First of all: (Where) Do you actually plan to pass a DB into your new function?
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.
I don't have any (yet), I was just trying to say that it's not that special and one can use it anywhere else if they need to.
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.
For me the last insert ID makes only sense for immediate subsequent processing – which just screams transaction. So I'd just allow Tx as parameter for now unless/until someone finds an actual use case with DB. (But then I'd:
- unexport the interface OR
- aggregate there all interfaces and non-interface methods both Tx and DB implement.)
@@ -43,6 +45,49 @@ func SplitOnDupId[T IDer]() com.BulkChunkSplitPolicy[T] { | |||
} | |||
} | |||
|
|||
// InsertObtainID executes the given query and fetches the last inserted 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.
... here due to how special it is.
89805fa
to
b9e7928
Compare
b9e7928
to
7a11e5d
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.
Please split pr the into two.
The commits are split into their own PRs so that this is no longer necessary. |
No description provided.