Permalink
Browse files

return decl name for constructors

  • Loading branch information...
1 parent 195f71e commit 3d8f6cc642579b331c007ced5428da71104ca0ca @JPMoresmau committed Mar 26, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/Scion/PersistentBrowser/Query.hs
View
10 src/Scion/PersistentBrowser/Query.hs
@@ -204,20 +204,20 @@ constructorsByName name = do consts <- selectList [ DbConstructorName ==. name ]
return $ map entityVal consts
-- | Gets a list of modules where a declaration may live
-getModulesWhereDeclarationIs :: String -> SqlPersist IO [DbModule]
+getModulesWhereDeclarationIs :: String -> SqlPersist IO [(DbModule,String)]
getModulesWhereDeclarationIs declName =
- do let sqlDecl = "SELECT DbModule.name, DbModule.doc, DbModule.packageId"
+ do let sqlDecl = "SELECT DbModule.name, DbModule.doc, DbModule.packageId,''"
++ " FROM DbDecl, DbModule"
++ " WHERE DbDecl.moduleId = DbModule.id AND DbDecl.name = ?"
- sqlCons = "SELECT DbModule.name, DbModule.doc, DbModule.packageId"
+ sqlCons = "SELECT DbModule.name, DbModule.doc, DbModule.packageId,DbDecl.name"
++ " FROM DbConstructor, DbDecl, DbModule"
++ " WHERE DbConstructor.declId = DbDecl.id AND DbDecl.moduleId = DbModule.id"
++ " AND DbConstructor.name = ?"
decls <- queryDb sqlDecl [declName] action
cons <- queryDb sqlCons [declName] action
return (decls ++ cons)
- where action :: [PersistValue] -> DbModule
- action [PersistText name, doc, pkgId@(PersistInt64 _)] = DbModule (T.unpack name) (fromDbText doc) (Key pkgId)
+ where action :: [PersistValue] -> (DbModule,String)
+ action [PersistText name, doc, pkgId@(PersistInt64 _),PersistText decl] = (DbModule (T.unpack name) (fromDbText doc) (Key pkgId),T.unpack decl)
action _ = error "This should not happen"
-- |Executes a query.

0 comments on commit 3d8f6cc

Please sign in to comment.