Skip to content

Getting Started page has outdated code #398

@slowdive-

Description

@slowdive-

Hi,

first of all thank you for your work on this project. Watching the video and reading through the examples this seems like an amazing library to use.

Unfortunately I have had some issues when trying to follow https://rel8.readthedocs.io/en/latest/tutorial.html

  • TableSchema.schema does not exist anymore. This seems to be fixed in https://github.com/circuithub/rel8/blob/master/docs/tutorial.rst but not on readthedocs.io
  • I had a very hard time figuring out how to actually run a Query, it took me multiple hours of hopping between hasql and rel8 documentation :( (Granted, I didn't have experience with either).
    • select conn (each projectSchema) does not work anymore
    • select (each projectSchema) gives me a Statement (Query (Project Expr)) so I tried to follow the types to see how this ever gets executed. hasql and rel8 both have a run function and a Statement type which makes it more confusing to figure out how to plumb things together.

For now, I ended up with this, but I have no idea if this is an idiomatic way of doing things:

allProjects :: Query (Project Expr)
allProjects = each projectSchema

runSelectAllProjects :: Hasql.Connection -> IO ()
runSelectAllProjects conn = do
    let rel8Statement = select allProjects -- Statement (Query (Project Expr))
        hasqlStatement = run rel8Statement -- Hasql.Statement () [Project Result]
        hasqlSession = Hasql.statement () hasqlStatement -- Hasql.Session [Project Result]
    resOrErr <- Hasql.run hasqlSession conn
    case resOrErr of
        Left sessErr -> error $ show sessErr
        Right res -> mapM_ print res

(I've imported everything from Hasql qualified to make it obvious to me where things come from).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions