Skip to content

Commit a890ed0

Browse files
committed
Apply formatter fixes to all modified files
1 parent 36795a0 commit a890ed0

13 files changed

Lines changed: 79 additions & 55 deletions

lib/ecto/adapters/libsql.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ defmodule Ecto.Adapters.LibSql do
280280

281281
defp json_array_decode(value) when is_binary(value) do
282282
case value do
283-
"" -> {:ok, []} # Empty string defaults to empty array
283+
# Empty string defaults to empty array
284+
"" ->
285+
{:ok, []}
286+
284287
_ ->
285288
case Jason.decode(value) do
286289
{:ok, decoded} when is_list(decoded) -> {:ok, decoded}
@@ -335,12 +338,14 @@ defmodule Ecto.Adapters.LibSql do
335338
end
336339

337340
defp json_encode(value) when is_binary(value), do: {:ok, value}
341+
338342
defp json_encode(value) when is_map(value) or is_list(value) do
339343
case Jason.encode(value) do
340344
{:ok, json} -> {:ok, json}
341345
{:error, _} -> :error
342346
end
343347
end
348+
344349
defp json_encode(value), do: {:ok, value}
345350

346351
defp array_encode(value) when is_list(value) do
@@ -349,5 +354,6 @@ defmodule Ecto.Adapters.LibSql do
349354
{:error, _} -> :error
350355
end
351356
end
357+
352358
defp array_encode(value), do: {:ok, value}
353359
end

test/ecto_returning_shared_schema_test.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ defmodule EctoLibSql.EctoReturningSharedSchemaTest do
99
use Ecto.Repo, otp_app: :ecto_libsql, adapter: Ecto.Adapters.LibSql
1010
end
1111

12-
alias EctoLibSql.Schemas.User # Using shared schema
12+
# Using shared schema
13+
alias EctoLibSql.Schemas.User
1314

1415
@test_db "z_ecto_libsql_test-shared_schema_returning.db"
1516

@@ -36,7 +37,7 @@ defmodule EctoLibSql.EctoReturningSharedSchemaTest do
3637

3738
test "insert shared schema user and get ID back" do
3839
IO.puts("\n=== Testing Shared Schema Insert RETURNING ===")
39-
40+
4041
result = LocalTestRepo.insert(%User{name: "Alice"})
4142
IO.inspect(result, label: "Insert result")
4243

test/ecto_returning_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ defmodule EctoLibSql.EctoReturningStructTest do
1010
import Ecto.Changeset
1111

1212
schema "users" do
13-
field :name, :string
14-
field :email, :string
13+
field(:name, :string)
14+
field(:email, :string)
1515
timestamps()
1616
end
1717

@@ -56,7 +56,7 @@ defmodule EctoLibSql.EctoReturningStructTest do
5656
case result do
5757
{:ok, user} ->
5858
IO.inspect(user, label: "Returned user struct")
59-
59+
6060
# These assertions should pass if RETURNING struct mapping works
6161
assert user.id != nil, "❌ FAIL: ID is nil (struct mapping broken)"
6262
assert is_integer(user.id) and user.id > 0, "ID should be positive integer"

test/ecto_sqlite3_blob_compat_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule EctoLibSql.EctoSqlite3BlobCompatTest do
22
@moduledoc """
33
Compatibility tests based on ecto_sqlite3 blob test suite.
4-
4+
55
These tests ensure that binary/blob field handling works identically to ecto_sqlite3.
66
"""
77

@@ -19,7 +19,7 @@ defmodule EctoLibSql.EctoSqlite3BlobCompatTest do
1919
setup_all do
2020
# Clean up any existing test database
2121
EctoLibSql.TestHelpers.cleanup_db_files(@test_db)
22-
22+
2323
# Configure the repo
2424
Application.put_env(:ecto_libsql, TestRepo,
2525
adapter: Ecto.Adapters.LibSql,

test/ecto_sqlite3_crud_compat_fixed_test.exs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ defmodule EctoLibSql.EctoSqlite3CrudCompatFixedTest do
8888

8989
test "insert user returns populated struct with id" do
9090
{:ok, user} = TestRepo.insert(%User{name: "Alice"})
91-
91+
9292
assert user.id != nil, "User ID should not be nil"
9393
assert user.name == "Alice"
9494
assert user.inserted_at != nil
@@ -97,13 +97,14 @@ defmodule EctoLibSql.EctoSqlite3CrudCompatFixedTest do
9797

9898
test "insert account and product" do
9999
{:ok, account} = TestRepo.insert(%Account{name: "TestAccount"})
100-
100+
101101
assert account.id != nil
102102

103-
{:ok, product} = TestRepo.insert(%Product{
104-
name: "TestProduct",
105-
account_id: account.id
106-
})
103+
{:ok, product} =
104+
TestRepo.insert(%Product{
105+
name: "TestProduct",
106+
account_id: account.id
107+
})
107108

108109
assert product.id != nil
109110
assert product.account_id == account.id
@@ -119,17 +120,17 @@ defmodule EctoLibSql.EctoSqlite3CrudCompatFixedTest do
119120

120121
test "update user" do
121122
{:ok, user} = TestRepo.insert(%User{name: "Charlie"})
122-
123+
123124
changeset = User.changeset(user, %{name: "Charles"})
124125
{:ok, updated} = TestRepo.update(changeset)
125-
126+
126127
assert updated.name == "Charles"
127128
end
128129

129130
test "delete user" do
130131
{:ok, user} = TestRepo.insert(%User{name: "David"})
131132
{:ok, _} = TestRepo.delete(user)
132-
133+
133134
assert TestRepo.get(User, user.id) == nil
134135
end
135136
end

test/ecto_sqlite3_crud_compat_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule EctoLibSql.EctoSqlite3CrudCompatTest do
22
@moduledoc """
33
Compatibility tests based on ecto_sqlite3 CRUD test suite.
4-
4+
55
These tests ensure that ecto_libsql adapter behaves identically to ecto_sqlite3
66
for basic CRUD operations.
77
"""

test/ecto_sqlite3_json_compat_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule EctoLibSql.EctoSqlite3JsonCompatTest do
22
@moduledoc """
33
Compatibility tests based on ecto_sqlite3 JSON test suite.
4-
4+
55
These tests ensure that JSON/MAP field serialization and deserialization
66
works identically to ecto_sqlite3.
77
"""
@@ -20,7 +20,7 @@ defmodule EctoLibSql.EctoSqlite3JsonCompatTest do
2020
setup_all do
2121
# Clean up any existing test database
2222
EctoLibSql.TestHelpers.cleanup_db_files(@test_db)
23-
23+
2424
# Configure the repo
2525
Application.put_env(:ecto_libsql, TestRepo,
2626
adapter: Ecto.Adapters.LibSql,
@@ -105,13 +105,13 @@ defmodule EctoLibSql.EctoSqlite3JsonCompatTest do
105105
end
106106

107107
test "json field with nil" do
108-
changeset =
108+
changeset =
109109
%Setting{}
110110
|> Setting.changeset(%{properties: nil})
111111
|> Ecto.Changeset.force_change(:properties, nil)
112-
112+
113113
IO.inspect(changeset, label: "Changeset before insert")
114-
114+
115115
setting = TestRepo.insert!(changeset)
116116

117117
fetched = TestRepo.get(Setting, setting.id)

test/ecto_sqlite3_returning_debug_test.exs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ defmodule EctoLibSql.EctoSqlite3ReturningDebugTest do
2020
{:ok, _} = EctoLibSql.Integration.TestRepo.start_link()
2121

2222
# Run migrations
23-
:ok = Ecto.Migrator.up(
24-
EctoLibSql.Integration.TestRepo,
25-
0,
26-
EctoLibSql.Integration.Migration,
27-
log: false
28-
)
23+
:ok =
24+
Ecto.Migrator.up(
25+
EctoLibSql.Integration.TestRepo,
26+
0,
27+
EctoLibSql.Integration.Migration,
28+
log: false
29+
)
2930

3031
on_exit(fn ->
3132
EctoLibSql.TestHelpers.cleanup_db_files(@test_db)
@@ -36,7 +37,7 @@ defmodule EctoLibSql.EctoSqlite3ReturningDebugTest do
3637

3738
test "insert returns user with ID" do
3839
IO.puts("\n=== Testing Repo.insert RETURNING ===")
39-
40+
4041
result = TestRepo.insert(%User{name: "Alice"})
4142
IO.inspect(result, label: "Insert result")
4243

test/ecto_sqlite3_timestamps_compat_test.exs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule EctoLibSql.EctoSqlite3TimestampsCompatTest do
22
@moduledoc """
33
Compatibility tests based on ecto_sqlite3 timestamps test suite.
4-
4+
55
These tests ensure that DateTime and NaiveDateTime handling works
66
identically to ecto_sqlite3.
77
"""
@@ -54,7 +54,7 @@ defmodule EctoLibSql.EctoSqlite3TimestampsCompatTest do
5454
setup_all do
5555
# Clean up any existing test database
5656
EctoLibSql.TestHelpers.cleanup_db_files(@test_db)
57-
57+
5858
# Configure the repo
5959
Application.put_env(:ecto_libsql, TestRepo,
6060
adapter: Ecto.Adapters.LibSql,
@@ -230,12 +230,13 @@ defmodule EctoLibSql.EctoSqlite3TimestampsCompatTest do
230230
all_products = Product |> select([p], {p.name, p.inserted_at}) |> TestRepo.all()
231231
IO.inspect(all_products, label: "All products")
232232

233-
result = Product
234-
|> select([p], p)
235-
|> where([p], p.inserted_at >= ago(2, "second"))
236-
|> order_by([p], desc: p.inserted_at)
237-
|> TestRepo.all()
238-
233+
result =
234+
Product
235+
|> select([p], p)
236+
|> where([p], p.inserted_at >= ago(2, "second"))
237+
|> order_by([p], desc: p.inserted_at)
238+
|> TestRepo.all()
239+
239240
IO.inspect(result, label: "Filtered result")
240241
assert [%{name: "Foo"}] = result
241242
end

test/returning_test.exs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ defmodule EctoLibSql.ReturningTest do
1111
{:ok, _, _} =
1212
DBConnection.execute(
1313
conn,
14-
%EctoLibSql.Query{statement: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)"},
14+
%EctoLibSql.Query{
15+
statement: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)"
16+
},
1517
[]
1618
)
1719

1820
# Insert with RETURNING
19-
query = %EctoLibSql.Query{statement: "INSERT INTO users (name, email) VALUES (?, ?) RETURNING id, name, email"}
21+
query = %EctoLibSql.Query{
22+
statement: "INSERT INTO users (name, email) VALUES (?, ?) RETURNING id, name, email"
23+
}
24+
2025
{:ok, _, result} = DBConnection.execute(conn, query, ["Alice", "alice@example.com"])
2126

2227
IO.inspect(result, label: "INSERT RETURNING result")

0 commit comments

Comments
 (0)