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] Add support for Some type in parameters #55

Closed
Darkle opened this issue Jul 4, 2023 · 1 comment
Closed

[Feature Request] Add support for Some type in parameters #55

Darkle opened this issue Jul 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Darkle
Copy link

Darkle commented Jul 4, 2023

It would be very handy if edgedb-net supported passing in a Some type in query parameters.

Since the edgedb-net client doesn't support passing in Some values, I have to manually unwrap the optionals to get the value or set them to null. Since you can already pass in a None value as a parameter, it would make things a lot simpler if you could also pass in a Some value too. That would mean I wouldn't have to unwrap them or set them to null.

A somewhat contrived example:
This doesnt work:

let getSinglePost (postId: string option) =
  let queryParams = new Dictionary<string, obj>()
  queryParams.Add("postId", postId)

  task {
    try
      let! results =
        dbClient.QuerySingleAsync<Post>(
          "select Post{*} filter .postId = <optional str>$postId",
          queryParams
        )

      return Ok(results)
    with err ->
      Logger.Error(message = "Error with getSinglePost", error = err)
      return Error err
  }

So I have to do:

let getSinglePost (postId: string option) =
  let pId = Option.defaultValue null postId
  let queryParams = new Dictionary<string, obj>()
  queryParams.Add("postId", pId)

  task {
    try
      let! results =
        dbClient.QuerySingleAsync<Post>(
          "select Post{*} filter .postId = <optional str>$postId",
          queryParams
        )

      return Ok(results)
    with err ->
      Logger.Error(message = "Error with getSinglePost", error = err)
      return Error err
  }
@Darkle Darkle changed the title Add support for Some type in parameters [Feature Request] Add support for Some type in parameters Jul 4, 2023
@quinchs quinchs added the enhancement New feature or request label Jul 10, 2023
@quinchs quinchs self-assigned this Jul 10, 2023
@quinchs
Copy link
Collaborator

quinchs commented Jul 13, 2023

Implemented in #58

@quinchs quinchs closed this as completed Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants