Functions I keep around when using Npgsql.FSharp

I have previously written about SqlFun and how I really like the library and its quasi-static type checking. However, at work I’m currently working with Npgsql.FSharp from the great Zaid Ajaj. I also like this library a lot, although, I don’t really appreciate some aspects of it.

You can see that someone also missed this functionality on issue #67. I volunteered to introduce it on the library too. In order to “fix” this issue, you can introduce the following code on your project:

namespace Npgsql.FShap

open Npgsql.FSharp

/// This module is an extension of the Npgsql.FSharp.Sql module
/// it contains useful functions not present on the library
module Sql =
    /// Executes a query and returns an optional with the results
    /// If no value is returned, returns None
    /// If values are found, returns Some
    let tryExecuteAsync read props =
        task {
            match! Sql.executeAsync read props with
            | [] -> return None
            | data -> return Some data

    /// Executes a query and returns an optional with the first result
    /// If no value is returned, returns None
    /// If values are found, returns the first one
    let tryExecuteRowAsync read props =
        task {
            match! tryExecuteAsync read props with
            | None -> return None
            | Some [] -> return None
            | Some(data :: _) -> return Some data

Articles from blogs I follow around the net

The four tenets of SOA revisited

Twenty years after. In the January 2004 issue of MSDN Magazine you can find an article by Don Box titled A Guide to Developing and Running Connected Systems with Indigo. Buried within the (now dated) discussion of the technology…

via ploeh blog March 4, 2024

Building a demo of the Bleichenbacher RSA attack in Rust

Recently while reading Real-World Cryptography, I got nerd sniped1 by the mention of Bleichenbacher's attack on RSA. This is cool, how does it work? I had to understand, and to understand something, I usually have to build it. Well, friends, that is what…

via blog March 4, 2024

How to unbreak Dolphin on SteamOS after the QT6 update

A recent update to Dolphin made it switch to QT6. This makes it crash with this error or something like it: dolphin-emu: symbol lookup error: dolphin-emu: undefined symbol: _Zls6QDebugRK11QDockWidget, version Qt_6 This is fix…

via Xe Iaso's blog March 3, 2024

Generated by openring