From c111f66d7de4e679b09aa54ef9fe851df6aa3ef8 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sat, 30 Jul 2016 09:32:53 +0000 Subject: [PATCH] SQL: Move some DBNames to common util module --- src/Database/Persist/Local/Sql.hs | 24 +++++++++++++++++++ src/Database/Persist/Sql/Graph/Connects.hs | 5 ---- src/Database/Persist/Sql/Graph/Cyclic.hs | 5 ---- src/Database/Persist/Sql/Graph/Path.hs | 5 ---- src/Database/Persist/Sql/Graph/Reachable.hs | 5 ---- .../Persist/Sql/Graph/TransitiveReduction.hs | 13 ---------- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/Database/Persist/Local/Sql.hs b/src/Database/Persist/Local/Sql.hs index a816557..14b2137 100644 --- a/src/Database/Persist/Local/Sql.hs +++ b/src/Database/Persist/Local/Sql.hs @@ -24,6 +24,12 @@ module Database.Persist.Local.Sql , sourceFieldFromProxy , (?:) , (?++) + , uedge + , temp + , tid + , tpath + , tcycle + , tcontains , FollowDirection (..) ) where @@ -158,3 +164,21 @@ infixr 5 ?: (?++) :: Maybe [a] -> [a] -> [a] (?++) = maybe id (++) infixr 5 ?++ + +uedge :: DBName +uedge = DBName "temp_undirected_edge_cte" + +temp :: DBName +temp = DBName "temp_hierarchy_cte" + +tid :: DBName +tid = DBName "id" + +tpath :: DBName +tpath = DBName "path" + +tcycle :: DBName +tcycle = DBName "cycle" + +tcontains :: DBName +tcontains = DBName "contains" diff --git a/src/Database/Persist/Sql/Graph/Connects.hs b/src/Database/Persist/Sql/Graph/Connects.hs index 5fce10f..5bbc86f 100644 --- a/src/Database/Persist/Sql/Graph/Connects.hs +++ b/src/Database/Persist/Sql/Graph/Connects.hs @@ -120,11 +120,6 @@ xmconnectsm' follow filter msource mdest mlen proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - uedge = DBName "temp_undirected_edge_cte" - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s diff --git a/src/Database/Persist/Sql/Graph/Cyclic.hs b/src/Database/Persist/Sql/Graph/Cyclic.hs index 52f4c66..98ea756 100644 --- a/src/Database/Persist/Sql/Graph/Cyclic.hs +++ b/src/Database/Persist/Sql/Graph/Cyclic.hs @@ -94,11 +94,6 @@ xcyclicn' follow filter minitials proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - uedge = DBName "temp_undirected_edge_cte" - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s diff --git a/src/Database/Persist/Sql/Graph/Path.hs b/src/Database/Persist/Sql/Graph/Path.hs index 18d75eb..b3f2f1e 100644 --- a/src/Database/Persist/Sql/Graph/Path.hs +++ b/src/Database/Persist/Sql/Graph/Path.hs @@ -120,11 +120,6 @@ xmpathm' follow filter msource mdest mlen mlim proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - uedge = DBName "temp_undirected_edge_cte" - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s diff --git a/src/Database/Persist/Sql/Graph/Reachable.hs b/src/Database/Persist/Sql/Graph/Reachable.hs index bc45b9e..7b9e136 100644 --- a/src/Database/Persist/Sql/Graph/Reachable.hs +++ b/src/Database/Persist/Sql/Graph/Reachable.hs @@ -93,11 +93,6 @@ xreachable' follow filter initials mlen proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - uedge = DBName "temp_undirected_edge_cte" - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s diff --git a/src/Database/Persist/Sql/Graph/TransitiveReduction.hs b/src/Database/Persist/Sql/Graph/TransitiveReduction.hs index b4624b8..03ef560 100644 --- a/src/Database/Persist/Sql/Graph/TransitiveReduction.hs +++ b/src/Database/Persist/Sql/Graph/TransitiveReduction.hs @@ -79,10 +79,6 @@ trrSelect proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn ecols = T.intercalate ", " $ entityColumnNames tEdge conn qecols name = @@ -166,10 +162,6 @@ trrApply proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcycle = DBName "cycle" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s @@ -258,11 +250,6 @@ trrFix edge proxy = do tEdge = entityDef $ dummyFromSnd proxy fwd = persistFieldDef $ destFieldFromProxy proxy bwd = persistFieldDef $ sourceFieldFromProxy proxy - temp = DBName "temp_hierarchy_cte" - tid = DBName "id" - tpath = DBName "path" - tcontains = DBName "cycle" - tcycle = DBName "contains" dbname = connEscapeName conn t ^* f = dbname t <> "." <> dbname f t <#> s = dbname t <> " INNER JOIN " <> dbname s