Questions tagged [haskell-persistent]

Persistent is a type-safe, universal data store interface for Haskell with support for various backends, including PostgreSQL, SQLite, MySQL and MongoDB.

57 questions
0
votes
1 answer

Haskell's Persistent sometmes returns 500 Internal Server Error

The following code launches a web server at localhost:3000. #!/usr/bin/env stack -- stack script --resolver=lts-12.16 {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs …
Marronnier
  • 389
  • 2
  • 10
0
votes
1 answer

NoLoggingT does not disable logging in Persistent

I've made this piece of code and I'm puzzled with two things: why do the two pieces work differently, one logging and another not? why does the second piece log if there is a NoLoggingT wrapper added on the selectFoobars? Code: {-# LANGUAGE…
Konstantine Rybnikov
  • 2,457
  • 1
  • 22
  • 29
0
votes
1 answer

Is it possible to define your own Persistent / Esqueleto lens?

Given the following persistent type: share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| Account email Text passphrase Text firstName Text lastName Text deriving Eq Show Generic |] What I think is a…
danbroooks
  • 2,712
  • 5
  • 21
  • 43
0
votes
1 answer

Haskell Persistent BackendFilter

I'm trying to use the match operator of Sqlite3 FTS3/4 tables with Persistent (in Yesod). I've succeeded in creating my own match operator: -- | Implements the `match` operator. This operator is specific to Sqlite3 and -- is used to look for…
zigazou
  • 1,725
  • 9
  • 13
0
votes
1 answer

Persistent upsert does not compile

I'm trying to do something in Persistent with PostgreSQL that seems like it should be simple: Given a list of Attendance records, overwrite any existing rows with same unique key or insert if they don't exist. Here are the types: share [mkPersist…
nnnmmm
  • 7,964
  • 4
  • 22
  • 41
0
votes
0 answers

Yesod Hardcoded Auth with database access

I implemented a Yesod auth system like described here, which works fine by looking up username and passwords hardcoded in a list. I now try to modify this behavior to lookup usernames and passwords in the database by modifying the lookupUser and…
Benjoyo
  • 413
  • 7
  • 13
0
votes
0 answers

Yesod/Persistent not closing DB connections

I have a web app that uses Yesod and Persistent. I'm using the default scaffolded Foundation.hs and Application.hs. I've written a function which processes a local JSON file, and then inserts a row into several tables for each item in the JSON…
Will
  • 1,893
  • 4
  • 29
  • 42
0
votes
1 answer

get persistent's field definitions for my model

given a persistent model definition like this: mkPersist sqlSettings [persistLowerCase| Person name String age Int deriving Show |] I'm looking for a way to get the field definitions for this model. FieldDef looks like a promising…
maillard
  • 680
  • 1
  • 14
  • 27
0
votes
1 answer

How to find out which key is conflicting when using the replaceUnique method?

I'm using the replaceUnique method, which has return type of ReaderT backend m (Maybe (Unique record)). My database table has two unique fields and if uniqueness is violated, I want to find out which key is conflicting. How can I do that?
Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177
0
votes
0 answers

Persistent: How can I get a random record from the database

I want to use persistent to fetch a number of records from the database, selected randomly. My first idea was to have an auto-incremented id field on the model, and fetch records by id. But I quickly concluded that this is probably not a good idea.…
maillard
  • 680
  • 1
  • 14
  • 27
0
votes
0 answers

Is it possible to use deleteCascade with esqueleto?

I did not found any mentions of deleteCascade and deleteCascadeWhere in esqueleto... Is there an esqueleto equivalent to these functions?
gueux
  • 323
  • 1
  • 12
0
votes
2 answers

Fetch a Persistent record given its integral key?

I'm trying to use Persistent with Servant, so I don't have the luxury of automatically parsing URL segments into Persistent keys. Instead, I've set up my routes to require an Int64, and I want to retrieve a record using that to perform primary key…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
1 2 3
4