Skip to content

Commit

Permalink
fix: raise if primary_key: true and no prefix (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloane authored Jul 16, 2023
1 parent c9eb03b commit dd8f957
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.5.1

- raises if `prefix` is not given when `primary_key: true`

## 0.5.0

- `Ecto.ParameterizedType` implementation traverses associations so prefixes only need to be defined on schema primary keys
Expand Down
2 changes: 1 addition & 1 deletion lib/type_id/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do
field = Keyword.fetch!(opts, :field)
default_type = Application.get_env(:typeid_elixir, :default_type, :string)
type = Keyword.get(opts, :type, default_type)
prefix = Keyword.get(opts, :prefix, "")
prefix = Keyword.get(opts, :prefix)

if primary_key do
unless prefix && prefix =~ ~r/^[a-z]{0,63}$/ do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule TypeID.MixProject do
use Mix.Project

@version "0.5.0"
@version "0.5.1"

def project do
[
Expand Down

0 comments on commit dd8f957

Please sign in to comment.