Skip to content

Allow array query params #41

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

Merged
merged 2 commits into from
Feb 12, 2024

Conversation

thanhnguyen2187
Copy link
Contributor

Resolve #40.


Sample curl:

curl \
    -X POST \
    --header 'Content-Type: application/json' \
    --data @/tmp/data.json \
    --fail-with-body \
    127.0.0.1:12321/crypta \
| jq

Sample body:

{
    "transaction": [
        {
            "statement": "CREATE TABLE table_with_many_columns (d INT, c INT, b INT, a INT)",
            "values": []
        },
        {
            "statement": "INSERT INTO table_with_many_columns VALUES (?, ?, ?, ?)",
            "values": [1, 1, 1, 1]
        },
        {
            "statement": "INSERT INTO table_with_many_columns VALUES (?, ?, ?, ?)",
            "valuesBatch": [
                [2, 2, 2, 2],
                [3, 3, 3, 3],
                [4, 4, 4, 4]
            ]
        },
        {
            "query": "SELECT * FROM table_with_many_columns"
        },
        {
            "statement": "DROP TABLE table_with_many_columns"
        }
    ]
}

Sample response:

{
  "results": [
    {
      "success": true,
      "rowsUpdated": 0
    },
    {
      "success": true,
      "rowsUpdated": 1
    },
    {
      "success": true,
      "rowsUpdatedBatch": [
        1,
        1,
        1
      ]
    },
    {
      "success": true,
      "resultSet": [
        {
          "d": 1,
          "c": 1,
          "b": 1,
          "a": 1
        },
        {
          "d": 2,
          "c": 2,
          "b": 2,
          "a": 2
        },
        {
          "d": 3,
          "c": 3,
          "b": 3,
          "a": 3
        },
        {
          "d": 4,
          "c": 4,
          "b": 4,
          "a": 4
        }
      ]
    },
    {
      "success": true,
      "rowsUpdated": 1
    }
  ]
}

@thanhnguyen2187
Copy link
Contributor Author

@proofrock I will rebase this after #38 is merged.

@proofrock proofrock self-assigned this Feb 12, 2024
@proofrock proofrock added the enhancement New feature or request label Feb 12, 2024
@proofrock
Copy link
Owner

Looks nice, thanks! Yes, let's rebase it after #38

@proofrock
Copy link
Owner

Thanks. There are still a couple of errors and conflicts, would you solve them (whenever you can)? Please try a "make test" afterwards.

./web_service.go:66:62: undefined: requestItemCrypto
./web_service.go:311:58: txItem.Decoder undefined (type requestItem has no field or method Decoder)

@proofrock
Copy link
Owner

Good code anyway, thanks! 👍

@thanhnguyen2187
Copy link
Contributor Author

Oh yep I'm trying to rebase, but it seems simpler to create a new branch and copy the changes manually anyway 😅. I'll let you know when the new branch is ready

@thanhnguyen2187 thanhnguyen2187 force-pushed the feature/array-query-params branch from 9d6b6d3 to 8115601 Compare February 12, 2024 09:15
@thanhnguyen2187
Copy link
Contributor Author

@proofrock it should be ready

@proofrock proofrock merged commit 97bdf07 into proofrock:main Feb 12, 2024
@proofrock
Copy link
Owner

Many thanks!!

@proofrock
Copy link
Owner

Next step is to write documentation for all that, but before I'd like to do the resultset format "change"

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

Successfully merging this pull request may close these issues.

Allow positional parameters
2 participants