Skip to content
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 SqlInsertStatementWriter which uses INSERT statements instead of SqlBulkCopy #510

Merged
merged 6 commits into from
Feb 15, 2024
Merged

Add SqlInsertStatementWriter which uses INSERT statements instead of SqlBulkCopy #510

merged 6 commits into from
Feb 15, 2024

Conversation

BrettJaner
Copy link
Contributor

@BrettJaner BrettJaner commented Jan 25, 2024

Addresses issue (#509)

Summary of changes:

  1. Add property called UseSqlBulkCopy to MSSqlServerSinkOptions defaulting to true
  2. Update configuration implementations in order to read UseSqlBulkCopy from appsettings.json
  3. Add SqlInsertStatementWriter which uses INSERT statements (highly based off of the SqlLogEventWriter used by the MSSqlServerAuditSink)
    • Implements both ISqlBulkBatchWriter and ISqlLogEventWriter
    • Removed SqlLogEventWriter as it is now redundant
  4. Add SqlInsertStatementWriterTests

@ckadluba
Copy link
Member

Hi @BrettJaner!

Thank you for the contribution. It is very welcome.

Can you please update the documentation in README.md to relfect your changes?

@BrettJaner
Copy link
Contributor Author

Can you please update the documentation in README.md to relfect your changes?

Hi @ckadluba, I've updated the README.md.

@BrettJaner
Copy link
Contributor Author

BrettJaner commented Feb 1, 2024

After reviewing my code for possible breaking changes, I realized I missed the configuration implementation (eg. ability to specify UseSqlBulkCopy in appsettings.json). I've since updated the PR (4a725ea). Please let me know if anything looks off.

@ckadluba
Copy link
Member

ckadluba commented Feb 2, 2024

@BrettJaner Can you please add also one integration test using the new SqlInsertBatchWriter? You'll find examples in the Misc directory, for instance this one: https://github.com/serilog-mssql/serilog-sinks-mssqlserver/blob/dev/test/Serilog.Sinks.MSSqlServer.Tests/Misc/OpenTelemetryColumnsTests.cs.

@BrettJaner
Copy link
Contributor Author

@BrettJaner Can you please add also one integration test using the new SqlInsertBatchWriter?

I've added integration tests to switch between the two batch writers (00cc7e9).

@BrettJaner BrettJaner requested a review from jonorossi February 14, 2024 15:27
@jonorossi jonorossi requested a review from ckadluba February 14, 2024 23:32
@BrettJaner BrettJaner changed the title Add SqlInsertBatchWriter which uses INSERT statements instead of SqlBulkCopy Add SqlInsertStatementWriter which uses INSERT statements instead of SqlBulkCopy Feb 15, 2024
Copy link
Member

@ckadluba ckadluba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. The new SqlInsertStatementWriter class looks good. :)

@ckadluba ckadluba added this pull request to the merge queue Feb 15, 2024
Merged via the queue into serilog-mssql:dev with commit 5786367 Feb 15, 2024
5 checks passed
@BrettJaner BrettJaner deleted the feat/insert-statement-batch-writer branch February 15, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants