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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

More BackendCompatible generalizations #723

Merged
merged 5 commits into from Nov 4, 2017

Conversation

Projects
None yet
3 participants
@parsonsmatt
Contributor

parsonsmatt commented Oct 24, 2017

This PR includes some additional generalizations. Unfortunately, my work project does not use the SqlReadT or SqlWriteT features, and it was only when the code was tested on those did the issues with Esqueleto come up.

This PR generalizes SqlReadT so that Esqueleto can be updated in a way that doesn't cause any breaking changes.

If any folks are using SqlReadT, I'd appreciate testing this PR/commit out with this Esqueleto PR to verify that it doesn't break any corner cases I've missed 馃槃

@@ -47,20 +47,20 @@ rawQueryRes sql vals = do
stmtQuery stmt vals
-- | Execute a raw SQL statement
rawExecute :: MonadIO m
rawExecute :: (MonadIO m, BackendCompatible SqlBackend backend)

This comment has been minimized.

@parsonsmatt

parsonsmatt Oct 24, 2017

Contributor

These functions needed to be generalized to satisfy Esqueleto.

@parsonsmatt

parsonsmatt Oct 24, 2017

Contributor

These functions needed to be generalized to satisfy Esqueleto.

@@ -27,6 +27,7 @@ import Control.Monad.Trans.Control (liftBaseOp_)
import Database.Persist.Sql.Types
import Database.Persist.Sql.Raw
import Database.Persist.Types
import Database.Persist.Sql.Orphan.PersistStore()

This comment has been minimized.

@parsonsmatt

parsonsmatt Oct 24, 2017

Contributor

This import is necessary for the BackendCompatible SqlBackend SqlBackend instance.

@parsonsmatt

parsonsmatt Oct 24, 2017

Contributor

This import is necessary for the BackendCompatible SqlBackend SqlBackend instance.

@dariooddenino

This comment has been minimized.

Show comment
Hide comment
@dariooddenino

dariooddenino Oct 25, 2017

Compilation of persistent-mysql-2.6.2 fails with this branch. persistent-mysql-2.6.1 works fine.

Progress: 2/3
--  While building package persistent-mysql-2.6.2 using:
      /home/dario/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/dario/dev/blue-moon/.stack-work/logs/persistent-mysql-2.6.2.log

    Configuring persistent-mysql-2.6.2...
    Building persistent-mysql-2.6.2...
    Preprocessing library persistent-mysql-2.6.2...
    [1 of 1] Compiling Database.Persist.MySQL ( Database/Persist/MySQL.hs, .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/Database/Persist/MySQL.o )
    
    /tmp/stack4584/persistent-mysql-2.6.2/Database/Persist/MySQL.hs:1188:17: error:
        鈥 Could not deduce (BackendCompatible r0 backend)
            arising from a use of 鈥榩rojectBackend鈥
          from the context: (backend ~ PersistEntityBackend record,
                             BackendCompatible SqlBackend backend,
                             PersistEntity record,
                             MonadIO m)
            bound by the type signature for:
                       insertManyOnDuplicateKeyUpdate :: (backend
                                                          ~
                                                          PersistEntityBackend record,
                                                          BackendCompatible SqlBackend backend,
                                                          PersistEntity record, MonadIO m) =>
                                                         [record]
                                                         -> [SomeField record]
                                                         -> [Update record]
                                                         -> ReaderT backend m ()
            at Database/Persist/MySQL.hs:(1175,1)-(1185,27)
          The type variable 鈥榬0鈥 is ambiguous
          Relevant bindings include
            insertManyOnDuplicateKeyUpdate :: [record]
                                              -> [SomeField record]
                                              -> [Update record]
                                              -> ReaderT backend m ()
              (bound at Database/Persist/MySQL.hs:1186:1)
          These potential instances exist:
            instance BackendCompatible SqlBackend SqlBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlReadBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlWriteBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
        鈥 In the first argument of 鈥榳ithReaderT鈥, namely 鈥榩rojectBackend鈥
          In the first argument of 鈥(.)鈥, namely 鈥榳ithReaderT projectBackend鈥
          In the expression: withReaderT projectBackend . uncurry rawExecute
    
    /tmp/stack4584/persistent-mysql-2.6.2/Database/Persist/MySQL.hs:1189:15: error:
        鈥 Could not deduce (BackendCompatible SqlBackend r0)
            arising from a use of 鈥榬awExecute鈥
          from the context: (backend ~ PersistEntityBackend record,
                             BackendCompatible SqlBackend backend,
                             PersistEntity record,
                             MonadIO m)
            bound by the type signature for:
                       insertManyOnDuplicateKeyUpdate :: (backend
                                                          ~
                                                          PersistEntityBackend record,
                                                          BackendCompatible SqlBackend backend,
                                                          PersistEntity record, MonadIO m) =>
                                                         [record]
                                                         -> [SomeField record]
                                                         -> [Update record]
                                                         -> ReaderT backend m ()
            at Database/Persist/MySQL.hs:(1175,1)-(1185,27)
          The type variable 鈥榬0鈥 is ambiguous
          These potential instances exist:
            instance BackendCompatible SqlBackend SqlBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlReadBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlWriteBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
        鈥 In the first argument of 鈥榰ncurry鈥, namely 鈥榬awExecute鈥
          In the second argument of 鈥(.)鈥, namely 鈥榰ncurry rawExecute鈥
          In the expression: withReaderT projectBackend . uncurry rawExecute

dariooddenino commented Oct 25, 2017

Compilation of persistent-mysql-2.6.2 fails with this branch. persistent-mysql-2.6.1 works fine.

Progress: 2/3
--  While building package persistent-mysql-2.6.2 using:
      /home/dario/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/dario/dev/blue-moon/.stack-work/logs/persistent-mysql-2.6.2.log

    Configuring persistent-mysql-2.6.2...
    Building persistent-mysql-2.6.2...
    Preprocessing library persistent-mysql-2.6.2...
    [1 of 1] Compiling Database.Persist.MySQL ( Database/Persist/MySQL.hs, .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/Database/Persist/MySQL.o )
    
    /tmp/stack4584/persistent-mysql-2.6.2/Database/Persist/MySQL.hs:1188:17: error:
        鈥 Could not deduce (BackendCompatible r0 backend)
            arising from a use of 鈥榩rojectBackend鈥
          from the context: (backend ~ PersistEntityBackend record,
                             BackendCompatible SqlBackend backend,
                             PersistEntity record,
                             MonadIO m)
            bound by the type signature for:
                       insertManyOnDuplicateKeyUpdate :: (backend
                                                          ~
                                                          PersistEntityBackend record,
                                                          BackendCompatible SqlBackend backend,
                                                          PersistEntity record, MonadIO m) =>
                                                         [record]
                                                         -> [SomeField record]
                                                         -> [Update record]
                                                         -> ReaderT backend m ()
            at Database/Persist/MySQL.hs:(1175,1)-(1185,27)
          The type variable 鈥榬0鈥 is ambiguous
          Relevant bindings include
            insertManyOnDuplicateKeyUpdate :: [record]
                                              -> [SomeField record]
                                              -> [Update record]
                                              -> ReaderT backend m ()
              (bound at Database/Persist/MySQL.hs:1186:1)
          These potential instances exist:
            instance BackendCompatible SqlBackend SqlBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlReadBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlWriteBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
        鈥 In the first argument of 鈥榳ithReaderT鈥, namely 鈥榩rojectBackend鈥
          In the first argument of 鈥(.)鈥, namely 鈥榳ithReaderT projectBackend鈥
          In the expression: withReaderT projectBackend . uncurry rawExecute
    
    /tmp/stack4584/persistent-mysql-2.6.2/Database/Persist/MySQL.hs:1189:15: error:
        鈥 Could not deduce (BackendCompatible SqlBackend r0)
            arising from a use of 鈥榬awExecute鈥
          from the context: (backend ~ PersistEntityBackend record,
                             BackendCompatible SqlBackend backend,
                             PersistEntity record,
                             MonadIO m)
            bound by the type signature for:
                       insertManyOnDuplicateKeyUpdate :: (backend
                                                          ~
                                                          PersistEntityBackend record,
                                                          BackendCompatible SqlBackend backend,
                                                          PersistEntity record, MonadIO m) =>
                                                         [record]
                                                         -> [SomeField record]
                                                         -> [Update record]
                                                         -> ReaderT backend m ()
            at Database/Persist/MySQL.hs:(1175,1)-(1185,27)
          The type variable 鈥榬0鈥 is ambiguous
          These potential instances exist:
            instance BackendCompatible SqlBackend SqlBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlReadBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
            instance BackendCompatible SqlBackend SqlWriteBackend
              -- Defined in 鈥榩ersistent-2.7.1:Database.Persist.Sql.Orphan.PersistStore鈥
        鈥 In the first argument of 鈥榰ncurry鈥, namely 鈥榬awExecute鈥
          In the second argument of 鈥(.)鈥, namely 鈥榰ncurry rawExecute鈥
          In the expression: withReaderT projectBackend . uncurry rawExecute
@parsonsmatt

This comment has been minimized.

Show comment
Hide comment
@parsonsmatt

parsonsmatt Nov 3, 2017

Contributor

Good catch @dariooddenino The generalizations I'm making here make the preemptive persistent-mysql generalizations unnecessary :)

Contributor

parsonsmatt commented Nov 3, 2017

Good catch @dariooddenino The generalizations I'm making here make the preemptive persistent-mysql generalizations unnecessary :)

@paul-rouse

This comment has been minimized.

Show comment
Hide comment
@paul-rouse

paul-rouse Nov 3, 2017

Contributor

@parsonsmatt This is looking good! Could you please rebase to the latest master, and make the changelog message describe the whole PR (include a link to the PR too) instead of saying it fixes a compilation error (which was just an intermediate step!)? Then, assuming travis is still OK, I can merge it.

Contributor

paul-rouse commented Nov 3, 2017

@parsonsmatt This is looking good! Could you please rebase to the latest master, and make the changelog message describe the whole PR (include a link to the PR too) instead of saying it fixes a compilation error (which was just an intermediate step!)? Then, assuming travis is still OK, I can merge it.

@parsonsmatt

This comment has been minimized.

Show comment
Hide comment
@parsonsmatt

parsonsmatt Nov 3, 2017

Contributor

Weird spurious build failure: https://travis-ci.org/yesodweb/persistent/jobs/296983378 Tests passed and all :\

Contributor

parsonsmatt commented Nov 3, 2017

Weird spurious build failure: https://travis-ci.org/yesodweb/persistent/jobs/296983378 Tests passed and all :\

@paul-rouse

This comment has been minimized.

Show comment
Hide comment
@paul-rouse

paul-rouse Nov 4, 2017

Contributor

Looked like a last-minute glitch. I restarted that test and it is fine now.

Thanks for all of this - I'll go ahead and merge it.

Contributor

paul-rouse commented Nov 4, 2017

Looked like a last-minute glitch. I restarted that test and it is fine now.

Thanks for all of this - I'll go ahead and merge it.

@paul-rouse paul-rouse merged commit 7c00533 into yesodweb:master Nov 4, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

MaxGabriel added a commit that referenced this pull request Dec 17, 2017

MaxGabriel added a commit that referenced this pull request Dec 17, 2017

MaxGabriel added a commit that referenced this pull request Dec 19, 2017

Merge pull request #759 from yesodweb/revert723
Revert "More BackendCompatible generalizations (#723)"

snoyberg added a commit that referenced this pull request Jan 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment