-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repo.delete! with string (uuid) (issue #57)
- Loading branch information
Showing
2 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module adapters_postgresql_repo_uuid_test | ||
|
||
using Test # @test | ||
using Octo.Adapters.PostgreSQL # Repo Schema Raw | ||
|
||
Repo.debug_sql() | ||
|
||
include("options.jl") | ||
|
||
Repo.connect(; | ||
adapter = Octo.Adapters.PostgreSQL, | ||
Options.for_postgresql... | ||
) | ||
|
||
struct PinkFloyd | ||
end | ||
Schema.model(PinkFloyd, table_name="PINK_FLOYD") | ||
|
||
Repo.execute([DROP TABLE IF EXISTS PinkFloyd]) | ||
|
||
# https://arctype.com/blog/postgres-uuid/ | ||
Repo.execute(Raw(""" | ||
CREATE TABLE PINK_FLOYD ( | ||
id uuid DEFAULT uuid_generate_v4(), | ||
album_name VARCHAR NOT NULL, | ||
PRIMARY KEY (id) | ||
) | ||
""")) | ||
|
||
Repo.insert!(PinkFloyd, [ | ||
(album_name="The Wall",), | ||
(album_name="The Dark Side of the Moon",), | ||
(album_name="Wish You Were Here",), | ||
(album_name="The Division Bell",), | ||
(album_name="Pulse",), | ||
(album_name="Meddle",), | ||
(album_name="Atom Heart Mother",), | ||
(album_name="The Final Cut",), | ||
]) | ||
|
||
df = Repo.query(PinkFloyd) | ||
@test size(df) == (8,) | ||
|
||
pk_ids = map(x -> x.id, df[1:2]) | ||
Repo.delete!(PinkFloyd, pk_ids) | ||
|
||
df = Repo.query(PinkFloyd) | ||
@test size(df) == (6,) | ||
|
||
Repo.disconnect() | ||
|
||
end # module adapters_postgresql_repo_uuid_test |