# `Tds.Ecto.VarChar`
[🔗](https://github.com/elixir-ecto/ecto_sql/blob/v3.14.0/lib/ecto/adapters/tds/types.ex#L214)

A Tds adapter Ecto Type that wraps erlang string into tuple so TDS driver
can understand if erlang string should be encoded as NVarChar or Varchar.

Due to some limitations in Ecto and Tds driver, it is not possible to
support collations other than the one set on connection during login.
Please be aware of this limitation if you plan to store varchar values in
your database using Ecto since you will probably lose some codepoints in
the value during encoding. Instead use `tds_encoding` library and first
encode value and then annotate it as `:binary` by calling `Ecto.Query.API.type/2`
in your query. This way all codepoints will be properly preserved during
insert to database.

# `t`

```elixir
@type t() :: String.t()
```

An erlang string

# `varchar`

```elixir
@type varchar() :: {String.t(), :varchar}
```

A value annotated as varchar.

# `cast`

```elixir
@spec cast(t() | varchar() | any()) :: {:ok, t()} | :error
```

Casts to string.

# `cast!`

```elixir
@spec cast!(t() | varchar() | any()) :: t()
```

Same as `cast/1` but raises `Ecto.CastError` on invalid arguments.

# `dump`

```elixir
@spec dump(t() | any()) :: {:ok, varchar()} | :error
```

Converts a string representing a VarChar into a tuple `{value, :varchar}`.

Returns `:error` if value is not binary.

# `embed_as`

# `equal?`

# `load`

```elixir
@spec load(t() | any()) :: {:ok, t()} | :error
```

Loads the DB type as is.

---

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