-
-
Notifications
You must be signed in to change notification settings - Fork 50
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 support for pgx.Batch
, closes #152
#179
[!] add support for pgx.Batch
, closes #152
#179
Conversation
pgx.Batch
, closes #152
Yes, I will look at the warnings later this week, I was pretty busy recently, so I didn't have much time to look into that. |
No problem at all! Take your time! I'm not planning to spend much time until the new year anyway :) |
# Conflicts: # pgxmock.go
…ions' into feature/152-support-batch-operations
@pashagolub PR should be fine now, I resolved the linter issues. Starting this week I have more spare time, so I should be more responsive in case there are some other comments/issues. |
Also raised jackc/pgx#1878 discussion about making |
Something I cannot implement with the new functionality. Would you please help me to build a test case for the code snippet from the pgx manual: conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
fmt.Printf("Unable to establish connection: %v", err)
return
}
batch := &pgx.Batch{}
batch.Queue("select 1 + 1").QueryRow(func(row pgx.Row) error {
var n int32
err := row.Scan(&n)
if err != nil {
return err
}
fmt.Println(n)
return err
})
batch.Queue("select 1 + 2").QueryRow(func(row pgx.Row) error {
var n int32
err := row.Scan(&n)
if err != nil {
return err
}
fmt.Println(n)
return err
})
batch.Queue("select 2 + 3").QueryRow(func(row pgx.Row) error {
var n int32
err := row.Scan(&n)
if err != nil {
return err
}
fmt.Println(n)
return err
})
err = conn.SendBatch(ctx, batch).Close()
if err != nil {
fmt.Printf("SendBatch error: %v", err)
return
} The trick here is every |
Hi, yes, you are correct, I didn't notice that. I will work on some better solutions, so that QueryRow() can have more sophisticated results :) |
No problem!
Me neither. But before you'll spend more time on this, I have an idea, that this feature should look like So in a few words, we just can replace implementation of I understand it basically means to throw your code away, sorry about that. I will completely understand if you won't work on this implementation. On the other hand I listed this feature for this year GSoC. Maybe it's worth to work on it during the GSoC program? If you're eligible to be a participant I'd love to accept your proposal. If you're not eligible for participating but eligible to be a mentor, I'd love to onboard you as a GSoC mentor. :) |
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.
🙃
This PR introduces functionality to properly test
SendBatch()
function.In the scope of this PR, there was created new helper structs:
BatchElement
,Batch
, andBatchResults
.An example, how to use batches in tests:
I would appreciate any comments and feedback.
~Magda