Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to specify query metadata to prevent column name clashes #8

Open
alexflav23 opened this issue Dec 30, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@alexflav23
Copy link
Member

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.

@alexflav23 alexflav23 self-assigned this Dec 30, 2017
@alexflav23 alexflav23 added this to the M1 milestone Dec 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant