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

PGlite.exec() returns result objects with misplaced affectedRows #91

Open
nurturenature opened this issue May 21, 2024 · 0 comments
Open

Comments

@nurturenature
Copy link

The return results of PGlite.exec() misplace affectedRows.

Here's an example of a query whose results show affectedRows:

  • missing from INSERTs
  • only present on last SELECT
  • as a total for the whole transaction on the last SELECT result
{
  "query": "SELECT k,v FROM lww WHERE k = 0; INSERT INTO lww (k,v) VALUES (1,'0') ON CONFLICT (k) DO UPDATE SET v = lww.v || ' ' || '0'; INSERT INTO lww (k,v) VALUES (2,'0') ON CONFLICT (k) DO UPDATE SET v = lww.v || ' ' || '0'; SELECT k,v FROM lww WHERE k = 1; SELECT k,v FROM lww WHERE k = 2; INSERT INTO lww (k,v) VALUES (3,'0') ON CONFLICT (k) DO UPDATE SET v = lww.v || ' ' || '0'; SELECT k,v FROM lww WHERE k = 3;"
}
[
  {
    "rows": [],
    "fields": [
      {
        "name": "k",
        "dataTypeID": 23
      },
      {
        "name": "v",
        "dataTypeID": 25
      }
    ]
  },
  {
    "rows": [],
    "fields": []
  },
  {
    "rows": [],
    "fields": []
  },
  {
    "rows": [
      {
        "k": 1,
        "v": "0 0"
      }
    ],
    "fields": [
      {
        "name": "k",
        "dataTypeID": 23
      },
      {
        "name": "v",
        "dataTypeID": 25
      }
    ]
  },
  {
    "rows": [
      {
        "k": 2,
        "v": "0 0 0 0"
      }
    ],
    "fields": [
      {
        "name": "k",
        "dataTypeID": 23
      },
      {
        "name": "v",
        "dataTypeID": 25
      }
    ]
  },
  {
    "rows": [],
    "fields": []
  },
  {
    "rows": [
      {
        "k": 3,
        "v": "0"
      }
    ],
    "fields": [
      {
        "name": "k",
        "dataTypeID": 23
      },
      {
        "name": "v",
        "dataTypeID": 25
      }
    ],
    "affectedRows": 3
  }
]
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