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

uuid values are not properly escaped in subquery #415

Closed
ousenko opened this issue Oct 26, 2018 · 2 comments
Closed

uuid values are not properly escaped in subquery #415

ousenko opened this issue Oct 26, 2018 · 2 comments
Assignees
Labels

Comments

@ousenko
Copy link

ousenko commented Oct 26, 2018

Usually there's no problem executing queries with UUID params. In debugger, statement might look kinda this:

... FROM some_table WHERE some_table.id = '19508260-d913-11e8-9f8b-f2801f1b9fd1'::uuid ...

However, when doing subquery ...:

SomeTable.join(OtherTable, JoinType.INNER, SomeTable.id, OtherTable.otherId)
      .select {...} 
      .withDistinct(true)
      .count()

...uuid is not properly escaped :

SELECT COUNT(*) FROM (SELECT DISTINCT ... ON ... WHERE some_table.some_id = d821af77-f698-4141-8f2b-79a14fba0b0f and ...)

..which results in exception:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "f2b"
  Position: 727
@Tapac Tapac self-assigned this Oct 26, 2018
@Tapac Tapac added the bug label Oct 26, 2018
@Tapac
Copy link
Contributor

Tapac commented Oct 26, 2018

Could you provide an exact query, because I can see a subquery part in one provided above?

@ousenko
Copy link
Author

ousenko commented Oct 26, 2018

Exact query is:

TableA.join(TableB, JoinType.INNER, TableA.id, TableB.refId)
                    .select {
                        (TableB.someUUIDField eq someUUIDVal) and
                                (TableA.otherField less otherVal)
                    }
                    .withDistinct(true)
                    .count()
object TableA ... {

   val id = uuid("id").primaryKey()
   ...

}

object TableB ... {

  val refId = uuid("ref_id").references(TableA.id /*, restrict cascade */)

  val someUUIDField = uuid("ref_to_table_c").references(TableC.id /*, restrict cascade */)
   ...

}

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

2 participants