-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The current problem is that unlike traditional JDBC, the postgres-async driver doesn't seem to return full namespace and prefix metadata for SQL query results. This makes it difficult to parse results such as product.guid vs stockorderitem.guid or to specify the parsers using prefix namespaces at all.
We need a way to define parsers under a namespace, just like anorm allows. Example:
implicit val businessParser: PostgresRowParser[Business] = for {
id <- get[UUID]("business.guid")
urn <- get[UUID]("business.guid").map(BusinessURN.apply)
name <- get[String]("business.name")
} yield Business(id, urn, name)Using this parser to extract results from an SQL ResultSet should be equivalent to using a parser definition without a namespace:
implicit val businessParser: PostgresRowParser[Business] = for {
id <- get[UUID]("guid")
urn <- get[UUID]("guid").map(BusinessURN.apply)
name <- get[String]("name")
} yield Business(id, urn, name)However, in the case of joins, the parser should rely on the defined metadata to distinguish columns with the same name that belong to different tables. A ResultSet in the case of join can contain columns from multiple tables, and parsers should be able to automatically make use of them.