We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
executeMany
The type of executeMany function is the following:
executeMany :: QueryParam p => MySQLConn -> Query -> [[p]] -> IO [OK]
But when I'm trying to pass an empty list as an argument of type [[p]] I see the following error:
[[p]]
ERRException (ERR {errCode = 1065, errState = "42000", errMsg = "Query was empty"})
I see two possible solutions to this problem:
NonEmpty [p]
Here is the complete code where I observe the error:
#! /usr/bin/env cabal {- cabal: build-depends: base >= 4.11 && < 4.12 , mysql-haskell ^>= 0.8.4.1 , io-streams -} {-# LANGUAGE OverloadedStrings #-} module Main where import Data.String (fromString) import Database.MySQL.Base import Database.MySQL.Connection (utf8mb4_unicode_ci) import qualified System.IO.Streams as Stream createSchema :: Query createSchema = fromString $ unlines [ "DROP TABLE IF EXISTS users;" , "CREATE TABLE users" , " ( id INT AUTO_INCREMENT PRIMARY KEY" , " , name TEXT NOT NULL" , " ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;" ] insertUser :: Query insertUser = "INSERT INTO users (name) VALUES (?)" main :: IO () main = do (greet, conn) <- connectDetail ConnectInfo { ciHost = "127.0.0.1" , ciPort = 3306 , ciUser = "root" , ciPassword = "password" , ciDatabase = "test_db" , ciCharset = utf8mb4_unicode_ci } print greet print =<< mapM (executeMany_ conn) [createSchema] print =<< executeMany conn insertUser ([] :: [[MySQLValue]]) (_defs, is) <- query_ conn "SELECT * FROM `users`" print =<< Stream.toList is
The text was updated successfully, but these errors were encountered:
I prefer the first behavior, would you like to send me a patch?
Sorry, something went wrong.
No branches or pull requests
The type of
executeMany
function is the following:But when I'm trying to pass an empty list as an argument of type
[[p]]
I see the following error:I see two possible solutions to this problem:
executeMany
function to do nothing when empty list is given.[[p]]
toNonEmpty [p]
.Here is the complete code where I observe the error:
The text was updated successfully, but these errors were encountered: