Skip to content
New issue

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

Always creates SymbolToField "id" instance #1497

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions persistent/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for persistent

## Unreleased

* [1497](https://github.com/yesodweb/persistent/pull/1497)
* Always generates `SymbolToField "id"` instance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be a minor version bump - may be best to roll up with #1503

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me. Anything I need to do / pay attention to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've finished everything that needed to be done in #1503 (re-requested review to be sure). Aside from this PR, is anything else planned for 2.14.6.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rebase after #1503 has been merged (adjust the changelog section)


## 2.14.5.1

* [#1496](https://github.com/yesodweb/persistent/pull/1496)
Expand Down
6 changes: 1 addition & 5 deletions persistent/Database/Persist/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2980,11 +2980,7 @@ mkSymbolToFieldInstances mps entityMap (fixEntityDef -> ed) = do
mkEntityFieldConstr fieldHaskellName
mkInstance fieldNameT fieldTypeT entityFieldConstr

mkey <-
case unboundPrimarySpec ed of
NaturalKey _ ->
pure []
_ -> do
mkey <- do
let
fieldHaskellName =
FieldNameHS "Id"
Expand Down
38 changes: 24 additions & 14 deletions persistent/test/Database/Persist/TH/OverloadedLabelSpec.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wname-shadowing -Werror=name-shadowing #-}

module Database.Persist.TH.OverloadedLabelSpec where

import TemplateTestImports
import TemplateTestImports

mkPersist sqlSettings [persistUpperCase|

Expand All @@ -33,6 +33,10 @@ Dog
Organization
name String

Student
userId UserId
departmentName String
Primary userId
|]

spec :: Spec
Expand Down Expand Up @@ -60,5 +64,11 @@ spec = describe "OverloadedLabels" $ do

compiles

it "works for Primary labels" $ do
let StudentId = #id
studentId = #id :: EntityField Student StudentId

compiles

compiles :: IO ()
compiles = pure ()