Skip to content

Commit f2a61ed

Browse files
author
Jason S
committed
Merge branch 'main' into js/pg-connection-test
2 parents 1cc2306 + 7882a01 commit f2a61ed

File tree

4 files changed

+115
-134
lines changed

4 files changed

+115
-134
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: warmwaffles

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This is a breaking change in the sense that rebuilding the schema from scratch w
1919

2020
We kept `TEXT_DATETIME` to satisfy the old Ecto2 implementation to keep backwards compatibility.
2121

22+
- **breaking**: raise when table prefixes are used. [#103](https://github.com/elixir-sqlite/ecto_sqlite3/pull/103)
2223

2324
## v0.9.1 - 2022-12-21
2425
- changed: Use `Connection.connect` instead of `Sqlite3.open`. [#96](https://github.com/elixir-sqlite/ecto_sqlite3/pull/96)

lib/ecto/adapters/sqlite3/connection.ex

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
5454
DBConnection.execute(conn, cached, params, options)
5555
end
5656

57-
@impl true
5857
def execute(
5958
conn,
6059
%Exqlite.Query{statement: statement, ref: nil},
@@ -64,7 +63,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
6463
execute(conn, statement, params, options)
6564
end
6665

67-
@impl true
6866
def execute(conn, sql, params, options) when is_binary(sql) or is_list(sql) do
6967
query = Exqlite.Query.build(name: "", statement: IO.iodata_to_binary(sql))
7068

@@ -75,7 +73,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
7573
end
7674
end
7775

78-
@impl true
7976
def execute(conn, query, params, options) do
8077
case DBConnection.execute(conn, query, params, options) do
8178
{:ok, _} = ok -> ok
@@ -163,7 +160,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
163160
raise ArgumentError, "locks are not supported by SQLite3"
164161
end
165162

166-
@impl true
167163
def all(query, as_prefix \\ []) do
168164
sources = create_names(query, as_prefix)
169165

@@ -233,7 +229,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
233229
raise ArgumentError, "JOINS are not supported on DELETE statements by SQLite"
234230
end
235231

236-
@impl true
237232
def delete_all(query) do
238233
sources = create_names(query, [])
239234
cte = cte(query, sources)
@@ -261,7 +256,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
261256
]
262257
end
263258

264-
@impl true
265259
def insert(prefix, table, header, rows, on_conflict, returning, _placeholders) do
266260
fields = quote_names(header)
267261

@@ -371,6 +365,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
371365
##
372366

373367
@impl true
368+
def execute_ddl({_command, %Table{options: options}, _}) when is_list(options) do
369+
raise ArgumentError, "SQLite3 adapter does not support keyword lists in :options"
370+
end
371+
374372
def execute_ddl({:create, %Table{} = table, columns}) do
375373
{table, composite_pk_def} = composite_pk_definition(table, columns)
376374
composite_fk_defs = composite_fk_definitions(table, columns)
@@ -390,7 +388,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
390388
]
391389
end
392390

393-
@impl true
394391
def execute_ddl({:create_if_not_exists, %Table{} = table, columns}) do
395392
{table, composite_pk_def} = composite_pk_definition(table, columns)
396393
composite_fk_defs = composite_fk_definitions(table, columns)
@@ -410,7 +407,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
410407
]
411408
end
412409

413-
@impl true
414410
def execute_ddl({:drop, %Table{} = table}) do
415411
[
416412
[
@@ -420,12 +416,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
420416
]
421417
end
422418

423-
@impl true
424419
def execute_ddl({:drop, %Table{} = table, _mode}) do
425420
execute_ddl({:drop, table})
426421
end
427422

428-
@impl true
429423
def execute_ddl({:drop_if_exists, %Table{} = table}) do
430424
[
431425
[
@@ -435,12 +429,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
435429
]
436430
end
437431

438-
@impl true
439432
def execute_ddl({:drop_if_exists, %Table{} = table, _mode}) do
440433
execute_ddl({:drop_if_exists, table})
441434
end
442435

443-
@impl true
444436
def execute_ddl({:alter, %Table{} = table, changes}) do
445437
Enum.map(changes, fn change ->
446438
[
@@ -599,16 +591,14 @@ defmodule Ecto.Adapters.SQLite3.Connection do
599591
quote_name(index.name),
600592
" ON ",
601593
quote_table(index.prefix, index.table),
602-
?\s,
603-
?(,
594+
" (",
604595
fields,
605596
?),
606597
if_do(index.where, [" WHERE ", to_string(index.where)])
607598
]
608599
]
609600
end
610601

611-
@impl true
612602
def execute_ddl({:create_if_not_exists, %Index{} = index}) do
613603
fields = intersperse_map(index.columns, ", ", &index_expr/1)
614604

@@ -621,21 +611,18 @@ defmodule Ecto.Adapters.SQLite3.Connection do
621611
quote_name(index.name),
622612
" ON ",
623613
quote_table(index.prefix, index.table),
624-
?\s,
625-
?(,
614+
" (",
626615
fields,
627616
?),
628617
if_do(index.where, [" WHERE ", to_string(index.where)])
629618
]
630619
]
631620
end
632621

633-
@impl true
634622
def execute_ddl({:create, %Constraint{}}) do
635623
raise ArgumentError, "SQLite3 does not support ALTER TABLE ADD CONSTRAINT."
636624
end
637625

638-
@impl true
639626
def execute_ddl({:drop, %Index{} = index}) do
640627
[
641628
[
@@ -645,12 +632,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
645632
]
646633
end
647634

648-
@impl true
649635
def execute_ddl({:drop, %Index{} = index, _mode}) do
650636
execute_ddl({:drop, index})
651637
end
652638

653-
@impl true
654639
def execute_ddl({:drop_if_exists, %Index{} = index}) do
655640
[
656641
[
@@ -660,22 +645,18 @@ defmodule Ecto.Adapters.SQLite3.Connection do
660645
]
661646
end
662647

663-
@impl true
664648
def execute_ddl({:drop_if_exists, %Index{} = index, _mode}) do
665649
execute_ddl({:drop_if_exists, index})
666650
end
667651

668-
@impl true
669652
def execute_ddl({:drop, %Constraint{}, _mode}) do
670653
raise ArgumentError, "SQLite3 does not support ALTER TABLE DROP CONSTRAINT."
671654
end
672655

673-
@impl true
674656
def execute_ddl({:drop_if_exists, %Constraint{}, _mode}) do
675657
raise ArgumentError, "SQLite3 does not support ALTER TABLE DROP CONSTRAINT."
676658
end
677659

678-
@impl true
679660
def execute_ddl({:rename, %Table{} = current_table, %Table{} = new_table}) do
680661
[
681662
[
@@ -687,7 +668,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
687668
]
688669
end
689670

690-
@impl true
691671
def execute_ddl({:rename, %Table{} = table, current_column, new_column}) do
692672
[
693673
[
@@ -701,10 +681,8 @@ defmodule Ecto.Adapters.SQLite3.Connection do
701681
]
702682
end
703683

704-
@impl true
705684
def execute_ddl(string) when is_binary(string), do: [string]
706685

707-
@impl true
708686
def execute_ddl(keyword) when is_list(keyword) do
709687
raise ArgumentError, "SQLite3 adapter does not support keyword lists in execute"
710688
end
@@ -1842,7 +1820,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
18421820
def quote_table(table), do: quote_entity(table)
18431821

18441822
defp quote_table(nil, name), do: quote_entity(name)
1845-
defp quote_table(prefix, name), do: [quote_entity(prefix), ?., quote_entity(name)]
1823+
1824+
defp quote_table(_prefix, _name) do
1825+
raise ArgumentError, "SQLite3 does not support table prefixes"
1826+
end
18461827

18471828
defp quote_entity(val) when is_atom(val) do
18481829
quote_entity(Atom.to_string(val))

0 commit comments

Comments
 (0)