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

Feature Request: Inject Format Variables for Query #76

Open
andrewjroth opened this issue Jul 7, 2023 · 0 comments
Open

Feature Request: Inject Format Variables for Query #76

andrewjroth opened this issue Jul 7, 2023 · 0 comments

Comments

@andrewjroth
Copy link

I'm using version 0.6.1 of this plugin. Thanks for supporting it!

I'm not sure if the language injection mentioned in #29 was already added or not, but I am able to annotate text strings in Kotlin to be recognized as Cypher and have the context menu items to Execute/Explain/Profile the Query (although, I think that is always available for any highlighted text).

I'm wondering if it might be possible to format the string with variables prior to being run. Variables are frequently used in database queries (Graph or SQL) to parameterize the query and reuse the query string for multiple queries. It would be helpful to be able to do this variable injection or provide parameters for a query when doing the Execute/Explain/Profile.

For example, given the Kotlin code below:

    @Language("Cypher")
    val ADD_MOVIE = """
      MERGE (movie:Movie {title: ${'$'}movieTitle})
      WITH movie
      MATCH (actor:Actor)
        WHERE actor.name IN ${'$'}movieActorNames
      MERGE (actor)-[:ACTED_IN]->(movie)
    """
    // ... elsewhere in the code ...
    // Official Neo4j Java Driver is used for Kotlin
    // The Query string is expected to have `$name` for parameter names, with values injected at runtime.
    // See https://neo4j.com/developer/java/
    tx.run(
      ADD_MOVIE,
      Values.parameters(
        "movieTitle", movie.title,
        "movieActorNames", movite.actors.map { it.name }
      )

I would like a context aware action to "Run with Parameters" that will prompt me for the parameters before running it against a configured database connection.

I'm willing to contribute a PR to add this, but don't really know where to start with adding this to the plugin. If I could get a pointer in the right direction, maybe I can make it happen.

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

No branches or pull requests

1 participant