{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE UndecidableInstances #-}

-- | More leaves cut from RQL.IR.Select for sake of breaking up the big pile of
-- things
module Hasura.RQL.IR.Select.RelationSelect
  ( AnnRelationSelectG (..),
  )
where

import Hasura.Prelude
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendType
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.Relationships.Local (Nullable)

-- Local relationship

data AnnRelationSelectG (b :: BackendType) a = AnnRelationSelectG
  { forall (b :: BackendType) a. AnnRelationSelectG b a -> RelName
_aarRelationshipName :: RelName, -- Relationship name
    forall (b :: BackendType) a.
AnnRelationSelectG b a -> HashMap (Column b) (Column b)
_aarColumnMapping :: HashMap (Column b) (Column b), -- Column of left table to join with
    forall (b :: BackendType) a. AnnRelationSelectG b a -> Nullable
_aarNullable :: Nullable, -- is the target object allowed to be missing?
    forall (b :: BackendType) a. AnnRelationSelectG b a -> a
_aarAnnSelect :: a -- Current table. Almost ~ to SQL Select
  }
  deriving stock ((forall a b.
 (a -> b) -> AnnRelationSelectG b a -> AnnRelationSelectG b b)
-> (forall a b.
    a -> AnnRelationSelectG b b -> AnnRelationSelectG b a)
-> Functor (AnnRelationSelectG b)
forall a b. a -> AnnRelationSelectG b b -> AnnRelationSelectG b a
forall a b.
(a -> b) -> AnnRelationSelectG b a -> AnnRelationSelectG b b
forall (b :: BackendType) a b.
a -> AnnRelationSelectG b b -> AnnRelationSelectG b a
forall (b :: BackendType) a b.
(a -> b) -> AnnRelationSelectG b a -> AnnRelationSelectG b b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (b :: BackendType) a b.
(a -> b) -> AnnRelationSelectG b a -> AnnRelationSelectG b b
fmap :: forall a b.
(a -> b) -> AnnRelationSelectG b a -> AnnRelationSelectG b b
$c<$ :: forall (b :: BackendType) a b.
a -> AnnRelationSelectG b b -> AnnRelationSelectG b a
<$ :: forall a b. a -> AnnRelationSelectG b b -> AnnRelationSelectG b a
Functor, (forall m. Monoid m => AnnRelationSelectG b m -> m)
-> (forall m a.
    Monoid m =>
    (a -> m) -> AnnRelationSelectG b a -> m)
-> (forall m a.
    Monoid m =>
    (a -> m) -> AnnRelationSelectG b a -> m)
-> (forall a b. (a -> b -> b) -> b -> AnnRelationSelectG b a -> b)
-> (forall a b. (a -> b -> b) -> b -> AnnRelationSelectG b a -> b)
-> (forall b a. (b -> a -> b) -> b -> AnnRelationSelectG b a -> b)
-> (forall b a. (b -> a -> b) -> b -> AnnRelationSelectG b a -> b)
-> (forall a. (a -> a -> a) -> AnnRelationSelectG b a -> a)
-> (forall a. (a -> a -> a) -> AnnRelationSelectG b a -> a)
-> (forall a. AnnRelationSelectG b a -> [a])
-> (forall a. AnnRelationSelectG b a -> Bool)
-> (forall a. AnnRelationSelectG b a -> Int)
-> (forall a. Eq a => a -> AnnRelationSelectG b a -> Bool)
-> (forall a. Ord a => AnnRelationSelectG b a -> a)
-> (forall a. Ord a => AnnRelationSelectG b a -> a)
-> (forall a. Num a => AnnRelationSelectG b a -> a)
-> (forall a. Num a => AnnRelationSelectG b a -> a)
-> Foldable (AnnRelationSelectG b)
forall a. Eq a => a -> AnnRelationSelectG b a -> Bool
forall a. Num a => AnnRelationSelectG b a -> a
forall a. Ord a => AnnRelationSelectG b a -> a
forall m. Monoid m => AnnRelationSelectG b m -> m
forall a. AnnRelationSelectG b a -> Bool
forall a. AnnRelationSelectG b a -> Int
forall a. AnnRelationSelectG b a -> [a]
forall a. (a -> a -> a) -> AnnRelationSelectG b a -> a
forall m a. Monoid m => (a -> m) -> AnnRelationSelectG b a -> m
forall b a. (b -> a -> b) -> b -> AnnRelationSelectG b a -> b
forall a b. (a -> b -> b) -> b -> AnnRelationSelectG b a -> b
forall (b :: BackendType) a.
Eq a =>
a -> AnnRelationSelectG b a -> Bool
forall (b :: BackendType) a. Num a => AnnRelationSelectG b a -> a
forall (b :: BackendType) a. Ord a => AnnRelationSelectG b a -> a
forall (b :: BackendType) m.
Monoid m =>
AnnRelationSelectG b m -> m
forall (b :: BackendType) a. AnnRelationSelectG b a -> Bool
forall (b :: BackendType) a. AnnRelationSelectG b a -> Int
forall (b :: BackendType) a. AnnRelationSelectG b a -> [a]
forall (b :: BackendType) a.
(a -> a -> a) -> AnnRelationSelectG b a -> a
forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> AnnRelationSelectG b a -> m
forall (b :: BackendType) b a.
(b -> a -> b) -> b -> AnnRelationSelectG b a -> b
forall (b :: BackendType) a b.
(a -> b -> b) -> b -> AnnRelationSelectG b a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall (b :: BackendType) m.
Monoid m =>
AnnRelationSelectG b m -> m
fold :: forall m. Monoid m => AnnRelationSelectG b m -> m
$cfoldMap :: forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> AnnRelationSelectG b a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> AnnRelationSelectG b a -> m
$cfoldMap' :: forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> AnnRelationSelectG b a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> AnnRelationSelectG b a -> m
$cfoldr :: forall (b :: BackendType) a b.
(a -> b -> b) -> b -> AnnRelationSelectG b a -> b
foldr :: forall a b. (a -> b -> b) -> b -> AnnRelationSelectG b a -> b
$cfoldr' :: forall (b :: BackendType) a b.
(a -> b -> b) -> b -> AnnRelationSelectG b a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> AnnRelationSelectG b a -> b
$cfoldl :: forall (b :: BackendType) b a.
(b -> a -> b) -> b -> AnnRelationSelectG b a -> b
foldl :: forall b a. (b -> a -> b) -> b -> AnnRelationSelectG b a -> b
$cfoldl' :: forall (b :: BackendType) b a.
(b -> a -> b) -> b -> AnnRelationSelectG b a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> AnnRelationSelectG b a -> b
$cfoldr1 :: forall (b :: BackendType) a.
(a -> a -> a) -> AnnRelationSelectG b a -> a
foldr1 :: forall a. (a -> a -> a) -> AnnRelationSelectG b a -> a
$cfoldl1 :: forall (b :: BackendType) a.
(a -> a -> a) -> AnnRelationSelectG b a -> a
foldl1 :: forall a. (a -> a -> a) -> AnnRelationSelectG b a -> a
$ctoList :: forall (b :: BackendType) a. AnnRelationSelectG b a -> [a]
toList :: forall a. AnnRelationSelectG b a -> [a]
$cnull :: forall (b :: BackendType) a. AnnRelationSelectG b a -> Bool
null :: forall a. AnnRelationSelectG b a -> Bool
$clength :: forall (b :: BackendType) a. AnnRelationSelectG b a -> Int
length :: forall a. AnnRelationSelectG b a -> Int
$celem :: forall (b :: BackendType) a.
Eq a =>
a -> AnnRelationSelectG b a -> Bool
elem :: forall a. Eq a => a -> AnnRelationSelectG b a -> Bool
$cmaximum :: forall (b :: BackendType) a. Ord a => AnnRelationSelectG b a -> a
maximum :: forall a. Ord a => AnnRelationSelectG b a -> a
$cminimum :: forall (b :: BackendType) a. Ord a => AnnRelationSelectG b a -> a
minimum :: forall a. Ord a => AnnRelationSelectG b a -> a
$csum :: forall (b :: BackendType) a. Num a => AnnRelationSelectG b a -> a
sum :: forall a. Num a => AnnRelationSelectG b a -> a
$cproduct :: forall (b :: BackendType) a. Num a => AnnRelationSelectG b a -> a
product :: forall a. Num a => AnnRelationSelectG b a -> a
Foldable, Functor (AnnRelationSelectG b)
Foldable (AnnRelationSelectG b)
Functor (AnnRelationSelectG b)
-> Foldable (AnnRelationSelectG b)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> AnnRelationSelectG b a -> f (AnnRelationSelectG b b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    AnnRelationSelectG b (f a) -> f (AnnRelationSelectG b a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> AnnRelationSelectG b a -> m (AnnRelationSelectG b b))
-> (forall (m :: * -> *) a.
    Monad m =>
    AnnRelationSelectG b (m a) -> m (AnnRelationSelectG b a))
-> Traversable (AnnRelationSelectG b)
forall (b :: BackendType). Functor (AnnRelationSelectG b)
forall (b :: BackendType). Foldable (AnnRelationSelectG b)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
AnnRelationSelectG b (m a) -> m (AnnRelationSelectG b a)
forall (b :: BackendType) (f :: * -> *) a.
Applicative f =>
AnnRelationSelectG b (f a) -> f (AnnRelationSelectG b a)
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AnnRelationSelectG b a -> m (AnnRelationSelectG b b)
forall (b :: BackendType) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AnnRelationSelectG b a -> f (AnnRelationSelectG b b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
AnnRelationSelectG b (m a) -> m (AnnRelationSelectG b a)
forall (f :: * -> *) a.
Applicative f =>
AnnRelationSelectG b (f a) -> f (AnnRelationSelectG b a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AnnRelationSelectG b a -> m (AnnRelationSelectG b b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AnnRelationSelectG b a -> f (AnnRelationSelectG b b)
$ctraverse :: forall (b :: BackendType) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AnnRelationSelectG b a -> f (AnnRelationSelectG b b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AnnRelationSelectG b a -> f (AnnRelationSelectG b b)
$csequenceA :: forall (b :: BackendType) (f :: * -> *) a.
Applicative f =>
AnnRelationSelectG b (f a) -> f (AnnRelationSelectG b a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
AnnRelationSelectG b (f a) -> f (AnnRelationSelectG b a)
$cmapM :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AnnRelationSelectG b a -> m (AnnRelationSelectG b b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AnnRelationSelectG b a -> m (AnnRelationSelectG b b)
$csequence :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
AnnRelationSelectG b (m a) -> m (AnnRelationSelectG b a)
sequence :: forall (m :: * -> *) a.
Monad m =>
AnnRelationSelectG b (m a) -> m (AnnRelationSelectG b a)
Traversable)

deriving stock instance (Backend b, Eq v) => Eq (AnnRelationSelectG b v)

deriving stock instance (Backend b, Show v) => Show (AnnRelationSelectG b v)