module Database.Beam.Query.Extract
(
ExtractField(..),
extract_,
hour_, minutes_, seconds_,
year_, month_, day_,
HasSqlTime, HasSqlDate
) where
import Database.Beam.Query.Internal ( QGenExpr(..) )
import Database.Beam.Backend.SQL ( BeamSqlBackend, BeamSqlBackendSyntax )
import Database.Beam.Backend.SQL.SQL92 ( Sql92ExtractFieldSyntax
, IsSql92ExpressionSyntax(..)
, IsSql92ExtractFieldSyntax(..) )
import Data.Time (LocalTime, UTCTime, TimeOfDay, Day)
newtype be tgt a
= (Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be))
extract_ :: BeamSqlBackend be
=> ExtractField be tgt a -> QGenExpr ctxt be s tgt -> QGenExpr cxt be s a
(ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
field) (QExpr TablePrefix
-> Sql92SelectTableExpressionSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))
expr) =
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionExtractFieldSyntax expr -> expr -> expr
extractE Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
field forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92SelectTableExpressionSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))
expr)
class HasSqlTime tgt
instance HasSqlTime LocalTime
instance HasSqlTime UTCTime
instance HasSqlTime TimeOfDay
hour_, minutes_, seconds_
:: ( BeamSqlBackend be, HasSqlTime tgt )
=> ExtractField be tgt Double
hour_ :: forall be tgt.
(BeamSqlBackend be, HasSqlTime tgt) =>
ExtractField be tgt Double
hour_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
hourField
minutes_ :: forall be tgt.
(BeamSqlBackend be, HasSqlTime tgt) =>
ExtractField be tgt Double
minutes_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
minutesField
seconds_ :: forall be tgt.
(BeamSqlBackend be, HasSqlTime tgt) =>
ExtractField be tgt Double
seconds_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
secondsField
class HasSqlDate tgt
instance HasSqlDate LocalTime
instance HasSqlDate UTCTime
instance HasSqlDate Day
year_, month_, day_
:: ( BeamSqlBackend be, HasSqlDate tgt )
=> ExtractField be tgt Double
year_ :: forall be tgt.
(BeamSqlBackend be, HasSqlDate tgt) =>
ExtractField be tgt Double
year_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
yearField
month_ :: forall be tgt.
(BeamSqlBackend be, HasSqlDate tgt) =>
ExtractField be tgt Double
month_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
monthField
day_ :: forall be tgt.
(BeamSqlBackend be, HasSqlDate tgt) =>
ExtractField be tgt Double
day_ = forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
dayField