Module

Droplet.Language.Internal.Translate

Package
purescript-droplet
Repository
easafe/purescript-droplet

ToQuery, a type class to generate parameterized SQL statement strings

Do not import this module directly, it will break your code and make it not type safe. Use the sanitized Droplet.Driver instead

#Query Source

data Query :: Row Type -> Typedata Query (projection :: Row Type)

Constructors

Instances

#QueryState Source

type QueryState = { bracketed :: Boolean, parameters :: Array Foreign, plan :: Maybe Plan }

#FilteredQuery Source

class FilteredQuery :: Type -> Row Type -> Constraintclass FilteredQuery (q :: Type) (outer :: Row Type) 

would be nice to dry this like tocondition, but gotta find a way to only check Paths Checks for invalid qualified columns usage in conditional clauses

Instances

#QualifiedProjection Source

class QualifiedProjection :: Type -> Row Type -> Row Type -> Constraintclass QualifiedProjection (s :: Type) (outer :: Row Type) (projection :: Row Type) | s -> outer projection

Validates qualified columns that ToProjection didn't have the context for

Instances

#TranslateSource Source

class TranslateSource (q :: Type)  where

Print field source

Members

Instances

#ToNakedProjection Source

class ToNakedProjection :: Type -> Row Type -> Constraintclass ToNakedProjection (s :: Type) (projection :: Row Type) 

Naked selects may be composed of subqueries whose projections need to be checked and merged individually

Instances

#SingleQualifiedColumn Source

class SingleQualifiedColumn :: RowList Type -> Type -> Row Type -> Constraintclass SingleQualifiedColumn (fields :: RowList Type) (q :: Type) (single :: Row Type) | fields -> q single

Projects a single qualified column, if it exists

Instances

#TranslateColumn Source

class TranslateColumn q  where

Print selected columns

Members

Instances

#NoAggregations Source

class NoAggregations :: Type -> Boolean -> Constraintclass NoAggregations (q :: Type) (is :: Boolean) | q -> is

Are all columns not aggregated?

Instances

#AggregatedQuery Source

class AggregatedQuery (s :: Type) (q :: Type) 

Asserts that queries not using GROUP BY do not mix aggregated and non aggregated columns

Instances

#ToReferenceDefinition Source

class ToReferenceDefinition :: RowList Type -> Constraintclass ToReferenceDefinition (source :: RowList Type)  where

Members

Instances

#IsValidAggregation Source

class IsValidAggregation :: Boolean -> Boolean -> Constraintclass IsValidAggregation (s :: Boolean) (t :: Boolean) 

Check aggregation results

Having a separated type class leads to better error messages

Instances

#CompositeConstraints Source

class CompositeConstraints :: RowList Type -> RowList Type -> Constraintclass CompositeConstraints (source :: RowList Type) (constraints :: RowList Type) | source -> constraints

Flatten constraints into a list

Instances

#CompositeFields Source

class CompositeFields :: Symbol -> RowList Type -> RowList Type -> Constraintclass CompositeFields (name :: Symbol) (rest :: RowList Type) (fields :: RowList Type) | name rest -> fields

Find all fields that are part of a composite constraint

Instances

#CompositeFieldList Source

#ToJoinType Source

class ToJoinType :: Side -> Constraintclass ToJoinType (k :: Side)  where

Print join type

Members

Instances

#SingleColumn Source

class SingleColumn :: Symbol -> Type -> RowList Type -> Constraintclass SingleColumn (name :: Symbol) (c :: Type) (output :: RowList Type) | name c -> output

Instances

#ToNullableDefinition Source

#ArgumentList Source

class ArgumentList v  where

Name list for functions, or when fields and parameters can be mixed

Members

Instances

#ReferenceList Source

class ReferenceList :: RowList Type -> RowList Type -> Constraintclass ReferenceList (source :: RowList Type) (constraints :: RowList Type) | source -> constraints

For foreign keys, we need a list of referenced fields

Instances

#ToCompositeConstraintDefinition Source

class ToCompositeConstraintDefinition (t :: Type)  where

While the rest stays the same, CONSTRAINT syntax uses and extra keyword for foreign keys

Members

Instances

#QueryMustNotBeAliased Source

class QueryMustNotBeAliased (q :: Type) 

Prevents top level queries to end in AS

Instances

#ToQuery Source

class ToQuery :: Type -> Row Type -> Constraintclass ToQuery (q :: Type) (projection :: Row Type) | q -> projection where

Builds a SQL query

Members

Instances

#TranslateNakedColumn Source

class TranslateNakedColumn q  where

Print naked selects

Members

Instances

#NameList Source

class NameList fieldNames  where

Names (possibly) separated by comma

Used by INSERT, ORDER BY

Members

Instances

#NameValuePairs Source

class NameValuePairs pairs  where

UPDATE list

Members

Instances

#ValueList Source

class ValueList fieldValues  where

Members

Instances

#Translate Source

class Translate q  where

Print SQL statements

Members

Instances

#buildQuery Source

buildQuery :: forall q projection. ToQuery q projection => q -> Query projection

#unsafeBuildQuery Source

unsafeBuildQuery :: forall projection parameters parameterList. RowToList parameters parameterList => ToParameters parameters parameterList => Maybe Plan -> String -> Record parameters -> Query projection