Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history


We can not trigger the GHC bug by using INLINABLE instead of INLINE
  • Loading branch information
mpscholten committed Oct 6, 2024
1 parent 7da31c2 commit 66518de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions IHP/QueryBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class HasQueryBuilder queryBuilderProvider joinRegister | queryBuilderProvider -
injectQueryBuilder :: QueryBuilder table -> queryBuilderProvider table
getQueryIndex :: queryBuilderProvider table -> Maybe ByteString
getQueryIndex _ = Nothing
{-# INLINE getQueryIndex #-}
{-# INLINABLE getQueryIndex #-}

-- Wrapper for QueryBuilders resulting from joins. Associates a joinRegister type.
newtype JoinQueryBuilderWrapper joinRegister table = JoinQueryBuilderWrapper (QueryBuilder table)
Expand All @@ -186,24 +186,24 @@ instance HasQueryBuilder QueryBuilder EmptyModelList where
-- JoinQueryBuilderWrappers have query builders
instance HasQueryBuilder (JoinQueryBuilderWrapper joinRegister) joinRegister where
getQueryBuilder (JoinQueryBuilderWrapper queryBuilder) = queryBuilder
{-# INLINE getQueryBuilder #-}
{-# INLINABLE getQueryBuilder #-}
injectQueryBuilder = JoinQueryBuilderWrapper
{-# INLINE injectQueryBuilder #-}
{-# INLINABLE injectQueryBuilder #-}

-- NoJoinQueryBuilderWrapper have query builders and the join register does not allow any joins
instance HasQueryBuilder NoJoinQueryBuilderWrapper NoJoins where
getQueryBuilder (NoJoinQueryBuilderWrapper queryBuilder) = queryBuilder
{-# INLINE getQueryBuilder #-}
{-# INLINABLE getQueryBuilder #-}
injectQueryBuilder = NoJoinQueryBuilderWrapper
{-# INLINE injectQueryBuilder #-}
{-# INLINABLE injectQueryBuilder #-}

instance (KnownSymbol foreignTable, foreignModel ~ GetModelByTableName foreignTable , KnownSymbol indexColumn, HasField indexColumn foreignModel indexValue) => HasQueryBuilder (LabeledQueryBuilderWrapper foreignTable indexColumn indexValue) NoJoins where
getQueryBuilder (LabeledQueryBuilderWrapper queryBuilder) = queryBuilder
{-# INLINE getQueryBuilder #-}
{-# INLINABLE getQueryBuilder #-}
injectQueryBuilder = LabeledQueryBuilderWrapper
{-# INLINE injectQueryBuilder #-}
{-# INLINABLE injectQueryBuilder #-}
getQueryIndex _ = Just $ symbolToByteString @foreignTable <> "." <> (Text.encodeUtf8 . fieldNameToColumnName) (symbolToText @indexColumn)
{-# INLINE getQueryIndex #-}
{-# INLINABLE getQueryIndex #-}


data QueryBuilder (table :: Symbol) =
Expand Down

0 comments on commit 66518de

Please sign in to comment.