question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support explicit transactions

See original GitHub issue

It would be great if we could add support for explicit custom transactions (http://www.npgsql.org/doc/transactions.html) to issue multiple nonqueries within one transaction. As far as I can see all executeNonQuery functions always just use List.head SqlProps.queries.

I am not sure about the API for this feature. It could be let executeNonQueryMany (props: SqlProps) : int list =

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rommsencommented, Apr 13, 2019

Awesome. Love it. Will probably use this API for pretty much all non queries. So flexible and composable

module PersistentReadmodels =
  open Infrastructure
  open Domain
  open Npgsql.FSharp

  let parameters eventEnvelope =
    match eventEnvelope.Event with
    | Flavour_sold (Truck truck,flavour) ->
        [
          "@truck", SqlValue.Uuid truck
          "@flavour", SqlValue.String (Flavour.toString flavour)
        ] |> Some

    | _ -> None

  let flavourSoldListener (DB_Connection_String db_connection) : EventListener<Event> =
    let query = """
      INSERT INTO flavours_sold (truck, flavour, sold) VALUES (@truck, @flavour, 1)
      ON CONFLICT (truck,flavour) DO UPDATE SET sold = flavours_sold.sold + 1"""

    fun eventEnvelopes ->
      let parameters =
        eventEnvelopes |> List.choose parameters

      if not <| List.isEmpty parameters then
        db_connection
        |> Sql.connect
        |> Sql.executeTransactionAsync [ query, parameters ]
        |> Async.Ignore
      else
        async { return () }
1reaction
rommsencommented, Apr 12, 2019

Awesome. Will try later

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explicit Transactions – SQLServerCentral
An explicit transaction is a transaction that is started with a BEGIN TRANSACTION statement and ends with either a COMMIT or ROLLBACK ...
Read more >
Modes of Transactions in SQL Server
SQL Server can operate 3 different transactions modes and these are: Auto-commit transactions; Implicit transactions; Explicit transactions.
Read more >
Handling explicit transactions after a failed operation
Rollback the current explicit transaction. This succeeds and would end the failed state of the explicit transaction. Validate that items ...
Read more >
Implementing an Explicit Transaction using ...
The CommittableTransaction class provides an explicit way for applications to use a transaction, as opposed to using the TransactionScope ...
Read more >
Support explicit transaction manager · Issue #255
ExplicitTransactionManager (as opposed to ThreadLocalTransactionManager) will allow supporting features that require switching threads ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found