From 8feb2556eda0604b6710309bf7ffddb72c22fc4a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 16 Jun 2022 01:06:04 +0200 Subject: foreign keys are a thing (and they can be useful, too!) Also, documentation & deleting imports / extensions that aren't used. --- lib/PersistOrphans.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/PersistOrphans.hs') diff --git a/lib/PersistOrphans.hs b/lib/PersistOrphans.hs index 68e9738..1f521cc 100644 --- a/lib/PersistOrphans.hs +++ b/lib/PersistOrphans.hs @@ -1,9 +1,9 @@ --- | This module contains instances for the Data.UUID UUID type --- to be mapped to postgresql's custom builtin uuid type. +-- | Instances for the Data.UUID UUID type to be mapped to postgresql's +-- custom builtin uuid type. -- -- Unfortunately, this breaks compatability with other SQL databases -- (though uuids aren't really supported by most anyways) -module PersistOrphans where +module PersistOrphans () where import Data.Either.Combinators (maybeToRight) @@ -25,8 +25,10 @@ instance PersistField UUID where maybeToRight "not a uuid (cannot decode)" $ UUID.fromASCIIBytes buf fromPersistValue v = Left $ "not a uuid (wrong type in database): " <> T.pack (show v) -- postgres is type-safe, so this should /hopefully/ never happen + instance PersistFieldSql UUID where sqlType = const $ SqlOther "uuid" + instance PathPiece UUID where fromPathPiece = UUID.fromText toPathPiece = UUID.toText -- cgit v1.2.3