Skip to content

Commit 581b514

Browse files
committed
Update readme and changelog
1 parent 4ce5b24 commit 581b514

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
# Changelog
77

8+
## v0.4.0 (2025-XX-XX)
9+
10+
### Enhancement
11+
- Improved SQL lexing performance with other 50% [91dc464](https://github.com/elixir-dbvisor/sql/commit/91dc464242d2e644b8c7210ac79bcf5f94c35ed8).
12+
- Added warnings for unknown operators [5bd7ec3](https://github.com/elixir-dbvisor/sql/commit/5bd7ec391c028a592dc4c94ead7a8002113790b9).
13+
- Added SQL.map/2 and implemented enumerable for SQL [a646203](https://github.com/elixir-dbvisor/sql/commit/a646203da05bc1e59b8f0df65b1a285ab1740a6c).
14+
- Added SQL Mix.Task.Compiler for sql files [4ce5b24](https://github.com/elixir-dbvisor/sql/commit/4ce5b243d2ec36d51bc1a3e5a25802b2d4a18b79).
15+
816
## v0.3.0 (2025-08-01)
917

1018
### Enhancement

README.md

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,53 +46,34 @@ iex(6)> inspect(sql)
4646
"~SQL\"\"\"\nselect\n id, \n email\nfrom\n users\nwhere\n email = {{email}}\n\"\"\""
4747
```
4848

49-
### Leverage the Enumerable protocol in your repository
50-
5149
```elixir
52-
defmodule MyApp.Repo do
53-
use Ecto.Repo, otp_app: :myapp, adapter: Ecto.Adapters.Postgres
54-
use SQL, adapter: SQL.Adapters.Postgres
50+
defmodule MyApp.Accounts do
51+
use SQL, adapter: SQL.Adapters.Postgres, repo: MyApp.Repo
5552

56-
defimpl Enumerable, for: SQL do
57-
def count(_enumerable) do
58-
{:error, __MODULE__}
59-
end
60-
def member?(_enumerable, _element) do
61-
{:error, __MODULE__}
62-
end
63-
def reduce(%SQL{} = enumerable, _acc, _fun) do
64-
{sql, params} = SQL.to_sql(enumerable)
65-
result = __MODULE__.query!(sql, params)
66-
{:done, Enum.map(result.rows, &Map.new(Enum.zip(result.columns, &1)))}
67-
end
68-
def slice(_enumerable) do
69-
{:error, __MODULE__}
70-
end
53+
def list_users() do
54+
~SQL[from users select *]
55+
|> SQL.map(fn row, columns, repo -> repo.load(User, {columns, row}) end)
56+
|> Enum.to_list()
7157
end
7258
end
7359

74-
iex(1)> Enum.map(~SQL[from users select *], &IO.inspect/1)
75-
%{"id" => 1, "email" => "john@example.com"}
76-
%{"id" => 2, "email" => "jane@example.com"}
77-
[%{"id" => 1, "email" => "john@example.com"}, %{"id" => 2, "email" => "jane@example.com"}]
60+
iex(1)> MyApp.Accounts.list_users()
61+
[%User{id: 1, email: "john@example.com"}, %User{id: 2, email: "jane@example.com"}]
7862
```
7963

8064
## Benchmark
8165
You can find benchmark results [here](https://github.com/elixir-dbvisor/sql/benchmarks) or run `mix sql.bench`
8266

8367
## Installation
8468

85-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
86-
by adding `sql` to your list of dependencies in `mix.exs`:
69+
The package can be installed by adding `sql` to your list of dependencies in `mix.exs`:
8770

8871
```elixir
8972
def deps do
9073
[
91-
{:sql, "~> 0.3.0"}
74+
{:sql, "~> 0.4.0"}
9275
]
9376
end
9477
```
9578

96-
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
97-
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
98-
be found at <https://hexdocs.pm/sql>.
79+
Documentation can be found at <https://hexdocs.pm/sql>.

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
defmodule SQL.MixProject do
55
use Mix.Project
66

7-
@version "0.3.0"
7+
@version "0.4.0"
88

99
def project do
1010
[

0 commit comments

Comments
 (0)