Repository navigation
Misc improvements from mochaa/main #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f224483
Remove deprecated parentheses after field access usage in tests
mochaaP 60407b7
Fix incorrectly named BinaryUUIDTest that didn't get loaded
mochaaP 53ff4f0
Support table-level check constraints
mochaaP ed0aa85
Stricter testing for raised error messages
mochaaP 539cfce
Support modifiers and drop mode
mochaaP 4c5fd49
Test query returns no result without prefix
mochaaP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,22 +160,21 @@ defmodule Ecto.Adapters.SQLite3 do | |
| ### Check constraints | ||
|
|
||
| SQLite3 supports specifying check constraints on the table or on the column definition. | ||
| We currently only support adding a check constraint via a column definition, since the | ||
| table definition approach only works at table-creation time and cannot be added at | ||
| table-alter time. You can see more information in the SQLite3 | ||
| [CREATE TABLE documentation](https://sqlite.org/lang_createtable.html). | ||
| Table-alter time check constraints are supported since SQLite 3.53.0. | ||
|
|
||
| Because of this, you cannot add a constraint via the normal `Ecto.Migration.constraint/3` | ||
| method, as that operates via `ALTER TABLE ADD CONSTRAINT`, and this type of `ALTER TABLE` | ||
| operation SQLite3 does not support. You can however get the full functionality by | ||
| adding a constraint at the column level, specifying the name and expression. Per the | ||
| SQLite3 documentation, there is no _functional_ difference between a column or table | ||
| constraint. | ||
| Adding a constraint via `Ecto.Migration.constraint/3` is recommended for new projects. | ||
| Note that SQLite's `ADD CONSTRAINTS` verifies existing rows with `WHERE (check) IS NOT TRUE`, | ||
| so make sure your check is NULL-safe. | ||
|
|
||
| Thus, adding a check constraint for a new column is as simple as: | ||
| As an adapter-specific extension, the old way of adding column-level constraints is still | ||
| available: | ||
|
|
||
| add :email, :string, check: %{name: "test_constraint", expr: "email != '[email protected]'"} | ||
|
|
||
| Note that column-level constraints are slightly different than table-level constraints, | ||
| since `DROP COLUMN` can drop column-level constraints but not table-level constraints. | ||
| Drop the constraint first before dropping the column in those cases. | ||
|
|
||
| ### Handling foreign key constraints in changesets | ||
|
|
||
| Unfortunately, unlike other databases, SQLite3 does not provide the precise name of | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally kept the
createandcreate_if_not_existsseparate for the executeddl stuff. Ya it's repeated, but it's clear what the function is for.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from ecto_sql. I could revert the changes if you'd like to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 it probably is better to stay as close to
ecto_sqlas possible. I do remember there being a reason why I split them other than "just feels" but I can't recall.