# `QuackDB.Sequence`
[🔗](https://github.com/elixir-vibe/quackdb/blob/main/lib/quack_db/sequence.ex#L1)

Helpers for DuckDB sequences.

Appends fill omitted columns from their defaults, including `nextval`
sequences. Use `next_values/4` when you need the IDs before writing, for
example to reference them from rows written in the same batch.

# `for_column`

```elixir
@spec for_column(
  DBConnection.conn() | module(),
  QuackDB.Meta.source(),
  atom() | String.t(),
  Keyword.t()
) :: {:ok, String.t()} | {:error, Exception.t()}
```

Returns the sequence backing a table column default.

This inspects `pragma_table_info` and returns the sequence referenced by a
`nextval('...')` default.

# `for_column!`

```elixir
@spec for_column!(
  DBConnection.conn() | module(),
  QuackDB.Meta.source(),
  atom() | String.t(),
  Keyword.t()
) :: String.t()
```

Returns the sequence backing a table column default, raising on errors.

# `next_values`

```elixir
@spec next_values(
  DBConnection.conn(),
  atom() | String.t(),
  non_neg_integer(),
  Keyword.t()
) :: [
  integer()
]
```

Returns `count` values from a DuckDB sequence.

    ids = QuackDB.Sequence.next_values(conn, "fragments_id_seq", 3)
    #=> [1, 2, 3]

The sequence name is encoded as a SQL string literal for `nextval/1`; callers
should pass the actual DuckDB sequence name, not raw SQL.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
