File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,24 +142,16 @@ defmodule Ecto.Adapters.LibSql.Connection do
142142
143143 if String . contains? ( constraint , ", " ) do
144144 # Multi-column constraint: "table.col1, table.col2" -> "table_col1_col2_index"
145- constraint
146- |> String . split ( ", " )
147- |> Enum . with_index ( )
148- |> Enum . map ( fn
149- { table_col , 0 } ->
150- # First column includes table name
151- table_col |> clean . ( ) |> String . replace ( "." , "_" )
152-
153- { table_col , _ } ->
154- # Subsequent columns: only take the column name
155- table_col
156- |> clean . ( )
157- |> String . split ( "." )
158- |> List . last ( )
159- |> clean . ( )
160- end )
161- |> Enum . concat ( [ "index" ] )
162- |> Enum . join ( "_" )
145+ [ first | rest ] = String . split ( constraint , ", " )
146+
147+ table_col = first |> clean . ( ) |> String . replace ( "." , "_" )
148+
149+ cols =
150+ Enum . map ( rest , fn col ->
151+ col |> clean . ( ) |> String . split ( "." ) |> List . last ( ) |> clean . ( )
152+ end )
153+
154+ [ table_col | cols ] |> Enum . concat ( [ "index" ] ) |> Enum . join ( "_" )
163155 else
164156 if String . contains? ( constraint , "." ) do
165157 # Single column: "table.column" -> "table_column_index"
You can’t perform that action at this time.
0 commit comments