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

Lost schema mapping when using infix (subqueries) #521

Closed
lbialy opened this issue Aug 20, 2016 · 1 comment · Fixed by #875
Closed

Lost schema mapping when using infix (subqueries) #521

lbialy opened this issue Aug 20, 2016 · 1 comment · Fixed by #875
Labels

Comments

@lbialy
Copy link

lbialy commented Aug 20, 2016

This is related to #520. When using infix to create subqueries mapping information defined via schema call is lost and column names are generated using given strategy, ie.: SnakeCase.

Version: new-encoding-SNAPSHOT
Module: quill-async

Given:

implicit class SubQuery[T](q: Query[T]) {
    def asSubQuery = quote(infix"$q".as[Query[T]])
}

case class User(id: Long, address: String, email: String, currentAge: Int, profileId: Long)

val users = quote {
    query[User].schema(_.columns(_.profileId -> "profileId", _.currentAge -> "currentAge")) // notice db columns are camelCase too
}

val underageUsers = quote {
    users.filter(i => i.currentAge < 18).asSubQuery
}

val underageUsersProfileIds = quote {
    underageUsers.map(u => u.profileId)
}

Expected behavior

Query generated should be:

SELECT i.profileId FROM (SELECT i.* FROM user i WHERE i.currentAge < 18) i

Actual behavior

Generated query ignores mappings:

SELECT i.profile_id, i.email FROM (SELECT i.* FROM user i WHERE i.current_age < 18) i

Workaround

Everything works fine as long as column names match results of applying selected name generation strategy to case class field names.

@getquill/maintainers

@fwbrasil
Copy link
Collaborator

fwbrasil commented Sep 6, 2017

still a valid bug: https://scalafiddle.io/sf/lsmX57J/123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants