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

[WIP] Trying to get postgres scaffold work with latest persistent #211

Merged
merged 2 commits into from
Oct 23, 2022

Conversation

schoettl
Copy link

@schoettl schoettl commented Oct 21, 2022

Fixes #210

Thanks for your help @snoyberg and @parsonsmatt!

Now that I tried the current scaffold from scratch, I found that it works because persistent-postgresql have correct bounds in package.yml (<2.11). Maybe I just apply this bounds in my projects, too.

I still created this PR as a basis for a future upgrade to a newer version of persistent. Hope that helps.

@parsonsmatt
Copy link

You'll need to update the version bounds here, too - that function was introduced after 2.11.

You could use CPP to work across persistent versions, but I'd rather have folks on newer versions 😄

@schoettl
Copy link
Author

So you say we better upgrade sooner than later?

Then, I'll need to change version boundaries to >= 2.13 && < 3?

@schoettl
Copy link
Author

yesod-form also advanced to 1.7.3 which I use and maybe that was the reason for stack resolving to use the incompatible persistent version.....

@schoettl
Copy link
Author

The next problem when I try to upgrade to a newer persistent version is this error:

/home/jakob/projects/yesod-scaffold/test/TestImport.hs:60:48: error:
    • Couldn't match expected type ‘Text’
                  with actual type ‘Database.Persist.SqlBackend.Internal.SqlBackend’
    • In the first argument of ‘getEscapedRawName’, namely ‘sqlBackend’
      In the first argument of ‘map’, namely
        ‘(getEscapedRawName sqlBackend)’
      In the expression: map (getEscapedRawName sqlBackend) tables
   |        
60 |     let escapedTables = map (getEscapedRawName sqlBackend) tables
   |                                                ^^^^^^^^^^

I can't find ask in the ChangeLog nor in Hoogle. How can I find out where it comes from and how to replace it? Oh, I finally found it in classy-prelude. But I'm afraid I don't understand the problem.

@parsonsmatt
Copy link

oh, i have the arguments backward, do a flip or operator section or maybe getEscapedRawNameFunction which will do m (Text -> Text) and specialize to SqlBackend -> Text -> Text

@schoettl
Copy link
Author

schoettl commented Oct 23, 2022

Thanks @parsonsmatt, now I got it, too. Alright, I pushed a version that seems to work.

stack test and build are working.

I only slightly changed the package version boundaries to make resolver lts-19.29 and lts-19.30 happy.

Should we merge that into postgres branch? And other branches are rebased on that? (Haven't read the complete README yet.)

Copy link
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

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

LGTM!

@snoyberg snoyberg merged commit 051e996 into yesodweb:postgres Oct 23, 2022
@snoyberg
Copy link
Member

This now has a bunch of name shadowing warnings, anyone have thoughts on why that's happening?

[ 1 of 12] Compiling Model

/home/michael/haskell/yesod-scaffold/yesod-scaffold/src/Model.hs:23:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘commentUserId’ shadows the existing binding
      defined at src/Model.hs:23:1
   |
23 | share [mkPersist sqlSettings, mkMigrate "migrateAll"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

/home/michael/haskell/yesod-scaffold/yesod-scaffold/src/Model.hs:23:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘commentMessage’ shadows the existing binding
      defined at src/Model.hs:23:1
   |
23 | share [mkPersist sqlSettings, mkMigrate "migrateAll"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

@schoettl
Copy link
Author

Oh, I missed that – for me it looks like the template function share causes that. But "share" is not mentioned in the ChangeLog. I have no idea.

@parsonsmatt
Copy link

It's this fix which is in 2.14.0.2, but not backported to 2.13.

@schoettl
Copy link
Author

OK, so it's good for now and should resolve at the next upgrade (as soon a new LTS is available and the bounds on persistent* in package.yml are increased to <2.15)

@snoyberg
Copy link
Member

Great, thanks! I've pushed the changes to the stack-templates repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants