Skip to content

Can't refer to UserId in an Id field #1149

Closed

Description

@parsonsmatt

This QQ breaks with an error that UserId is not in scope.

share [ mkPersist sqlSettings ] [persistLowerCase|

User
    name    String

Profile
    Id      UserId
    email   String
|]

However, using UserId is usually fine in other contexts. So why isn't this working?

Activity

  1. parsonsmatt commented on Apr 23, 2021

    @parsonsmatt
    CollaboratorAuthor

    I think I figured out what's going on here

    There's a type SqlTypeExp that, when lifted into a Q Exp, will either splice in the SqlType directly, or, if it's a SqlTypeExp FieldType, will translate the FieldType into a Template Haskell Type, and then splice a call like [| sqlType (Proxy :: Proxy $(fieldTypeToType fieldType) ) |].

    There's a bunch of other tricks, and I guess what's happening is that we're trying to lookup a UserId before the alias is defined.

  2. added this to the 2.13 milestone on May 4, 2021
  3. linked a pull request that will close this issueQuasiQuoter Improvements #1256on May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions