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 -> BeamSqlBackendExpressionSyntax be
expr) =
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr cxt be s a
forall context be s t.
(TablePrefix -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Sql92ExpressionExtractFieldSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionExtractFieldSyntax expr -> expr -> expr
extractE Sql92ExpressionExtractFieldSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
field (Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> (TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
-> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TablePrefix
-> Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
TablePrefix -> BeamSqlBackendExpressionSyntax 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_ :: ExtractField be tgt Double
hour_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
hourField
minutes_ :: ExtractField be tgt Double
minutes_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
minutesField
seconds_ :: ExtractField be tgt Double
seconds_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
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_ :: ExtractField be tgt Double
year_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
yearField
month_ :: ExtractField be tgt Double
month_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
monthField
day_ :: ExtractField be tgt Double
day_ = Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt Double
forall be tgt a.
Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
-> ExtractField be tgt a
ExtractField Sql92ExtractFieldSyntax (BeamSqlBackendSyntax be)
forall extractField.
IsSql92ExtractFieldSyntax extractField =>
extractField
dayField