Skip to content

Commit 91483d5

Browse files
committed
Remove guard clause use and expand the function
1 parent 44e2537 commit 91483d5

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

lib/ecto/adapters/exqlite/connection.ex

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,22 +398,38 @@ defmodule Ecto.Adapters.Exqlite.Connection do
398398
end
399399

400400
@impl true
401-
def execute_ddl({command, %Index{} = index})
402-
when command in [:create, :create_if_not_exists] do
401+
def execute_ddl({:create, %Index{} = index}) do
403402
fields = intersperse_map(index.columns, ", ", &index_expr/1)
404403

405404
[
406405
[
407406
"CREATE ",
408407
if_do(index.unique, "UNIQUE "),
409-
"INDEX",
410-
if_do(command == :create_if_not_exists, " IF NOT EXISTS"),
411-
?\s,
408+
"INDEX ",
412409
quote_name(index.name),
413410
" ON ",
414411
quote_table(index.prefix, index.table),
415-
?\s,
416-
?(,
412+
" (",
413+
fields,
414+
?),
415+
if_do(index.where, [" WHERE ", to_string(index.where)])
416+
]
417+
]
418+
end
419+
420+
@impl true
421+
def execute_ddl({:create_if_not_exists, %Index{} = index}) do
422+
fields = intersperse_map(index.columns, ", ", &index_expr/1)
423+
424+
[
425+
[
426+
"CREATE ",
427+
if_do(index.unique, "UNIQUE "),
428+
"INDEX IF NOT EXISTS ",
429+
quote_name(index.name),
430+
" ON ",
431+
quote_table(index.prefix, index.table),
432+
" (",
417433
fields,
418434
?),
419435
if_do(index.where, [" WHERE ", to_string(index.where)])

0 commit comments

Comments
 (0)