use :prefix to query attached databases - #183
Conversation
1a07fb1 to
b84d420
Compare
|
to maintainers: you may also want to pick changes from mochaa/main. |
cfce3b8 to
ad3b608
Compare
|
|
|
||
| - changed: Reimplement querying prefix names. | ||
| - added: Raise on cross-database foreign keys. | ||
| - changed: **breaking** Made quote_name/1 private. |
There was a problem hiding this comment.
Not really a breaking change. If someone was relying on that obscure function on the adapter from their application. That's a them problem. 🤣
| - changed: **breaking** Made quote_name/1 private. | |
| - changed: Made `quote_name/1` private. |
|
Is there any way on the integration side you can add a prefix test or two specifically for sqlite. I just want to make sure this functionality works and stays working going forward. You are free to construct schemas and stuff however you want for it. |
in |
|
Yes, anywhere in there is fine with me. Construct it however you want. |
ad3b608 to
73be09a
Compare
|
not sure how should I do that, ATTACH DATABASE is per connection and current test repo pool size is 5 |
73be09a to
42a94a7
Compare
|
Actually that migration test should be sufficient enough since that's executed in the integration tests. |
|
also tests are a bit flaky because sqlite expects single writer. |
|
well, does this count? defmodule Ecto.Integration.PrefixTest do
use Ecto.Integration.Case, async: true
import Ecto.Query, only: [from: 2]
alias Ecto.Integration.Post
alias Ecto.Integration.TestRepo
test "queries an attached database through :prefix" do
TestRepo.query!(~s|ATTACH DATABASE ":memory:" AS "foo"|)
TestRepo.query!(~s|CREATE TABLE "foo"."posts" AS SELECT * FROM "main"."posts"|)
TestRepo.insert!(%Post{id: 1}, prefix: "foo")
results =
from(Post, prefix: "foo")
|> TestRepo.all()
assert [%Post{id: 1}] = results
end
end |
Revert "raise on table prefixes" This reverts commit 71ddd0a. As a side effect, the quoting changes also Fixes: eca58dd ("Add support for :check constraint at column level (elixir-sqlite#29)")
42a94a7 to
e0b8407
Compare
|
Yea that works |
Reverts "raise on table prefixes" (71ddd0a, 7882a01, #103).
Supersedes #175, thanks @sbaildon.