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

Generated code is using full qualifier names #1939

Closed
fardavide opened this issue Sep 6, 2020 · 13 comments · Fixed by #1940
Closed

Generated code is using full qualifier names #1939

fardavide opened this issue Sep 6, 2020 · 13 comments · Fixed by #1940
Labels

Comments

@fardavide
Copy link

Build Environment
SQLDelight version: 1.4.3
OS: MacOS Big Sur beta
Gradle version: 6.6-rc-6-all
Kotlin version: 1.4.0

Describe the bug
Generated code does use full qualifier names and this clashes with my database.* package.

I have my sq files in database/src/commonMain/sqldelight/database/*
Gradle configured as following

sqldelight {
    database("Database") {
        packageName = "database"
    }
}

I've used this setup on SqlDelight 1.4.0 and 1.4.1 and there was no error as it was generating something like
image

But now it's generating something like:
image

that clashes with private val database: DatabaseImpl, while it should be as following, since the correct import is already there
image

@fardavide fardavide added the bug label Sep 6, 2020
@AlecKazakova
Copy link
Collaborator

the problem here is that the database part of database.movies.YearRangeWithRating is resolving to the type database instead of the package database?

@fardavide
Copy link
Author

fardavide commented Sep 6, 2020

No, we have private val database: DatabaseImpl as member of the class
image
So when tryin to resolve database as package name, it clashes with that property, so ye, I think full qualifier here is not needed and I wish to do not change my package name.

FYI: still ok until 1.4.2

@fardavide
Copy link
Author

@AlecStrong are you some kind of robot? 🙃

@AlecKazakova
Copy link
Collaborator

haha i had a hunch what the fix would be, once thats merged try the snapshot and let me know if its still broken

@fardavide
Copy link
Author

Where is hosted the snapshot? Didn't find on the website

@AlecKazakova
Copy link
Collaborator

True the documentation for that is no longer on the site, I added that back here: #1941

once the pull request to fix this issue is merged a snapshot will be published ~30min after that, then you can depend on it by doing

buildscript {
  repositories {
    maven {
      url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
  }
  dependencies {
    classpath "com.squareup.sqldelight:gradle-plugin:1.5.0-SNAPSHOT"
  }
}

@fardavide
Copy link
Author

Thank you, I'll keep an eye on it!

@fardavide
Copy link
Author

fardavide commented Sep 6, 2020

I confirm to be solved
image

Just a note, don't wanna bother with a new issues, unless I should 🙂 : probably is there temporally as is a snapshot version or maybe it is intentional, dunno about the policies, but there is an import from an internal pkg

import com.squareup.sqldelight.internal.copyOnWriteList

@AlecKazakova
Copy link
Collaborator

i think thats fine, its just intended to to say "this should only be used by sqldelight-generated code"

@JakeWharton
Copy link
Member

Intentional. For use by generated code only.

@AlecKazakova
Copy link
Collaborator

Screen Shot 2020-09-06 at 4 47 15 PM

rekt

@eygraber
Copy link
Contributor

eygraber commented Sep 7, 2020

@AlecStrong will KotlinPoet use the FQN if needed (like with this issue #1925)? If so, I think there will still be a problem if #1925 and #1939 both occur. One potential workaround is to mangle the property names in generated classes.

@AlecKazakova
Copy link
Collaborator

yes, it will use the FQN if there is a collision

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.

4 participants