Skip to content

[BUG]: Unexpected auto-generated SERIAL column values when using IndexedDB filesystemΒ #858

@Us3r-gitHub

Description

@Us3r-gitHub

Describe the bug

When using PGlite with IndexedDB filesystem, a SERIAL primary key increments by 33 on each insert instead of incrementing by 1.
This does not happen when using the default (in-memory) storage.

To Reproduce

Code Sample
<script setup lang="ts">
import { ref } from 'vue'
import { PGlite } from '@electric-sql/pglite'
import { live } from '@electric-sql/pglite/live'

const PGliteDB = await PGlite.create('idb://my-database', {
  extensions: {
    live,
  },
})

// Default (Memory)
// const PGliteDB = await PGlite.create({
//   extensions: {
//     live,
//   },
// })

const todo = ref()

await PGliteDB.exec(`
  CREATE TABLE IF NOT EXISTS todo (
    id SERIAL PRIMARY KEY,
    task TEXT
  );

  INSERT INTO todo (task) VALUES ('task');
`)

todo.value = await PGliteDB.exec('SELECT * FROM todo;')
</script>

<template>
  <pre>{{ todo }}</pre>
</template>
Repository

Minimal reproduction repository:
πŸ‘‰ on branch (vue-pglite)


Logs / Screenshots

Using IndexedDB
Image
Using in-memory
Image

Comparison

Storage type Behavior
In-memory (default) βœ… Increments by 1
IndexedDB (idb://) ❌ Increments by 33

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions