-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
These two ranges seem to be duplicated. The second one seems "more complete", it has exceptions on constraints and uses prefix in table renaming. Except, what are table prefixes in SQLite?
ecto_sqlite3/lib/ecto/adapters/sqlite3/connection.ex
Lines 460 to 562 in 6dcc0b2
@impl true | |
def execute_ddl({:create, %Index{} = index}) do | |
fields = intersperse_map(index.columns, ", ", &index_expr/1) | |
[ | |
[ | |
"CREATE ", | |
if_do(index.unique, "UNIQUE "), | |
"INDEX ", | |
quote_name(index.name), | |
" ON ", | |
quote_table(index.prefix, index.table), | |
" (", | |
fields, | |
?), | |
if_do(index.where, [" WHERE ", to_string(index.where)]) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:create_if_not_exists, %Index{} = index}) do | |
fields = intersperse_map(index.columns, ", ", &index_expr/1) | |
[ | |
[ | |
"CREATE ", | |
if_do(index.unique, "UNIQUE "), | |
"INDEX IF NOT EXISTS ", | |
quote_name(index.name), | |
" ON ", | |
quote_table(index.prefix, index.table), | |
" (", | |
fields, | |
?), | |
if_do(index.where, [" WHERE ", to_string(index.where)]) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:drop, %Index{} = index}) do | |
[ | |
[ | |
"DROP INDEX ", | |
quote_table(index.prefix, index.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:drop, %Index{} = index, _mode}) do | |
execute_ddl({:drop, index}) | |
end | |
@impl true | |
def execute_ddl({:drop_if_exists, %Index{} = index}) do | |
[ | |
[ | |
"DROP INDEX IF EXISTS ", | |
quote_table(index.prefix, index.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:drop_if_exists, %Index{} = index, _mode}) do | |
execute_ddl({:drop_if_exists, index}) | |
end | |
@impl true | |
def execute_ddl({:rename, %Table{} = current_table, %Table{} = new_table}) do | |
[ | |
[ | |
"ALTER TABLE ", | |
quote_table(current_table.prefix, current_table.name), | |
" RENAME TO ", | |
quote_table(nil, new_table.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:rename, %Table{} = current_table, old_col, new_col}) do | |
[ | |
[ | |
"ALTER TABLE ", | |
quote_table(current_table.prefix, current_table.name), | |
" RENAME COLUMN ", | |
quote_name(old_col), | |
" TO ", | |
quote_name(new_col) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl(string) when is_binary(string), do: [string] | |
@impl true | |
def execute_ddl(keyword) when is_list(keyword) do | |
raise ArgumentError, "SQLite3 adapter does not support keyword lists in execute" | |
end |
and
ecto_sqlite3/lib/ecto/adapters/sqlite3/connection.ex
Lines 564 to 685 in 6dcc0b2
@impl true | |
def execute_ddl({:create, %Index{} = index}) do | |
fields = intersperse_map(index.columns, ", ", &index_expr/1) | |
[ | |
[ | |
"CREATE ", | |
if_do(index.unique, "UNIQUE "), | |
"INDEX", | |
?\s, | |
quote_name(index.name), | |
" ON ", | |
quote_table(index.prefix, index.table), | |
?\s, | |
?(, | |
fields, | |
?), | |
if_do(index.where, [" WHERE ", to_string(index.where)]) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:create_if_not_exists, %Index{} = index}) do | |
fields = intersperse_map(index.columns, ", ", &index_expr/1) | |
[ | |
[ | |
"CREATE ", | |
if_do(index.unique, "UNIQUE "), | |
"INDEX IF NOT EXISTS", | |
?\s, | |
quote_name(index.name), | |
" ON ", | |
quote_table(index.prefix, index.table), | |
?\s, | |
?(, | |
fields, | |
?), | |
if_do(index.where, [" WHERE ", to_string(index.where)]) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:create, %Constraint{}}) do | |
raise ArgumentError, "SQLite3 does not support ALTER TABLE ADD CONSTRAINT." | |
end | |
@impl true | |
def execute_ddl({:drop, %Index{} = index}) do | |
[ | |
[ | |
"DROP INDEX ", | |
quote_table(index.prefix, index.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:drop, %Index{} = index, _mode}) do | |
execute_ddl({:drop, index}) | |
end | |
@impl true | |
def execute_ddl({:drop_if_exists, %Index{} = index}) do | |
[ | |
[ | |
"DROP INDEX IF EXISTS ", | |
quote_table(index.prefix, index.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:drop_if_exists, %Index{} = index, _mode}) do | |
execute_ddl({:drop_if_exists, index}) | |
end | |
@impl true | |
def execute_ddl({:drop, %Constraint{}, _mode}) do | |
raise ArgumentError, "SQLite3 does not support ALTER TABLE DROP CONSTRAINT." | |
end | |
@impl true | |
def execute_ddl({:drop_if_exists, %Constraint{}, _mode}) do | |
raise ArgumentError, "SQLite3 does not support ALTER TABLE DROP CONSTRAINT." | |
end | |
@impl true | |
def execute_ddl({:rename, %Table{} = current_table, %Table{} = new_table}) do | |
[ | |
[ | |
"ALTER TABLE ", | |
quote_table(current_table.prefix, current_table.name), | |
" RENAME TO ", | |
quote_table(new_table.prefix, new_table.name) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl({:rename, %Table{} = table, current_column, new_column}) do | |
[ | |
[ | |
"ALTER TABLE ", | |
quote_table(table.prefix, table.name), | |
" RENAME COLUMN ", | |
quote_name(current_column), | |
" TO ", | |
quote_name(new_column) | |
] | |
] | |
end | |
@impl true | |
def execute_ddl(string) when is_binary(string), do: [string] | |
@impl true | |
def execute_ddl(keyword) when is_list(keyword) do | |
raise ArgumentError, "SQLite3 adapter does not support keyword lists in execute" | |
end |
Metadata
Metadata
Assignees
Labels
No labels