-
Notifications
You must be signed in to change notification settings - Fork 540
Add run configuration for sqlite #2718
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 run configuration for sqlite #2718
Conversation
What the fuck yes that’s amazing |
if you’ll allow some nerd sniping this would be amazing if you could tell it to connect to a live db, like something on disk or running android app |
884dbf2
to
1cfdaac
Compare
Yes I wanted to add a dialog to pick a database file. As for Android, what's the right way to do it? I might peek into database inspector in AS. |
Will probably have to get creative, we can pull the database with adb, but
I would look at the source for things like stetho or even android studio
itself to see how they connect. Jake might have other ideas too. Ideally we
integrate with the inspector as much as possible but tbh I kinda like the
picnic output
…On Sat, Dec 4, 2021 at 9:46 AM Alexander Perfilyev ***@***.***> wrote:
Yes I wanted to add a dialog to pick a database file. As for Android,
what's the right way to do it? I might peek into database inspector in AS.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2718 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMZBQDJT3Q6GLE2DX6T343UPISVFANCNFSM5JKQ3QLQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Untitled.movI've made integration with AS database inspector but it requires IJ 2021.3. Is there a way to depend both on Android Studio and Intellij? |
WOW that is amazing. Is the problem that you need to compile against android SDKs for this to work? |
Yes, I have to specify either intellij.localPath=/path/to/Android Studio.app or intellij.version=2021.3 for it to compile |
if you dont specify those which classes cant be found? The thing I'm thinking is specifying a The other alternatives are to ship separate plugins, which I think is what most folks do but sounds like a lot of work, or just wait until Android Studio stable is on 2021.3, it looks like the bumblebee beta is on 2021.1 so presumably the one after that will be 2021.3? |
it can't find new database inspector classes that are not present in ij-203.
I'm not sure it will work because it throws a bunch of ClassNotFoundException if I specify android studio in runIde config. :/
Chipmunk is on 2021.2, unfortunately if you wanna play with it, you can check this commit aperfilyev@9a2e0ad |
coolcool, i'll give that a shot |
1cfdaac
to
41f6396
Compare
dolphin is 2021.3, I think we just wait for that to release and then merge this as is bumping our minimum intellij up, probably the easiest thing to do |
Yes, and I hope it doesn't take another year before it becomes stable. Should I send a pr? |
id wait to update this until we're getting close to the next sqldelight release and depending on what stage dolphin is at we can merge it |
It's supposed to be 4 month cycles so June-ish. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an initial skim through of the high level stuff. I think these abstractions are the right direction, and theres probably small stuff we could do to extend them to other dialects+connection types.
throw SQLException("The file path is empty") | ||
} | ||
|
||
return DriverManager.getConnection("jdbc:sqlite:$filePath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should reuse this class for DatabaseFileViewProvider
too, and steal its logic to make sure its loading from the correct plugin classloader #3080
} | ||
} | ||
|
||
internal class ConnectionManagerImpl(private val project: Project) : ConnectionManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is actually the only thing thats dialect-specific. I don't know if its worth promoting into the dialect api but at least for testing we could try bundling like the postgres jdbc artifact and prompting the user for the connection url. Doesnt have to be in this PR, just spitballing
private val dialogFactory: ArgumentsInputDialog.Factory = ArgumentsInputDialogFactoryImpl() | ||
) : AnAction() { | ||
|
||
override fun actionPerformed(e: AnActionEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this would be visible along with the android studio action that we just merged in - the implementations are actually so similar it seems like this AnAction
stuff might be able to just detect if android is around and use that to connect vs the custom jdbc stuff
var connectionType: ConnectionType by connectionType(project) | ||
} | ||
|
||
internal class SelectConnectionTypeDialog( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay and then this is the thing where it would be sweet if we could somehow find localhost ports that have a valid db running to connect to. If thats even possible we can probably just skim IntelliJ source code to find something that already does it, but again not for this PR
5666ba1
to
9cdb929
Compare
FYI I'm gonna play around on this branch and might push some stuff, but I'll do it as separate commits instead of force pushing so we don't step on each others toes |
This looks really awesome! |
ideally yes, but because those APIs are likely closed source it might be impossible. @aperfilyev 's trick for the AS Database inspector might also work here though, creating a fake .sql file that just delegates to the gutter action ultimate would create for that file. Worth trying at some point but no guarantees it will work |
Okay here's where its at Screen.Recording.2022-04-20.at.10.18.13.PM.movI'm pretty happy with this as a starting point. Some follow ups possible after this:
Will open this up for review then, I'll do a self review before merging but @aperfilyev might want to give things a look over too to make sure my changes make sense |
cb7d557
to
b136d5c
Compare
b136d5c
to
7dfa704
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the best I could
...elight-compiler/dialect/src/main/kotlin/app/cash/sqldelight/dialect/api/SqlDelightDialect.kt
Outdated
Show resolved
Hide resolved
...ite-3-18/src/main/kotlin/app/cash/sqldelight/dialects/sqlite_3_18/SqliteConnectionManager.kt
Show resolved
Hide resolved
sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt
Show resolved
Hide resolved
sqldelight-idea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/ProjectService.kt
Show resolved
Hide resolved
} | ||
|
||
private val _result = mutableListOf<SqlParameter>() | ||
override val result: List<SqlParameter> = _result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit:
override val result: List<SqlParameter> = _result | |
override val result: List<SqlParameter> get() = _result |
avoid redundant backing property
The code looks good upd: nevermind, it seems related to the specified dialect version |
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
* Add run configuration for sqlite * Add some tests * Run spotless * Fix up code so it works with master * Remove need for an identifier * Reuse ConnectionManager in compiler module * Move the connection manager to the dialect API * Remove tests and run spotless * Simplify RunSqlAction * Update sqldelight-idea-plugin/src/main/resources/META-INF/plugin.xml * Address feedback Co-authored-by: Alec Strong <[email protected]> Co-authored-by: Alec Strong <[email protected]>
Would you be interested in something like this?
Screen.Recording.2021-12-03.at.23.04.40.mov