Capture back-face printing images for double-faced cards
Add a back_image_uri column to printings, populated during ingest from a card's second card_faces image (only present for transform/MDFC/ reversible cards — split/adventure cards share one combined image and correctly get ""). Plumb it through CardRef across every query path (search, library, filters, deck contents) via the same printing row, using a shared deterministic ORDER BY so front/back always come from one printing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,16 @@ const LIBRARY_MIGRATIONS: &[&str] = &[
|
||||
/// The attached alias under which the reference db is available at runtime.
|
||||
pub const REF_DB: &str = "ref";
|
||||
|
||||
/// Correlated subquery selecting one image URL for the oracle card aliased `oc`.
|
||||
/// Returns NULL when no printing has an image. Read it as `Option<String>`.
|
||||
pub fn image_subquery() -> String {
|
||||
/// Correlated subquery selecting one column from the same printing (the first,
|
||||
/// by `rowid`, with a non-empty front image) for the oracle card aliased `oc`.
|
||||
/// Call once per desired column (e.g. `"image_uri"`, `"back_image_uri"`) — the
|
||||
/// shared `ORDER BY p.rowid` ensures they all resolve to the *same* printing
|
||||
/// row. Returns NULL when no printing has an image; read as `Option<String>`.
|
||||
pub fn image_subquery(column: &str) -> String {
|
||||
format!(
|
||||
"(SELECT p.image_uri FROM {REF_DB}.printings p
|
||||
WHERE p.oracle_id = oc.oracle_id AND p.image_uri <> '' LIMIT 1)"
|
||||
"(SELECT p.{column} FROM {REF_DB}.printings p
|
||||
WHERE p.oracle_id = oc.oracle_id AND p.image_uri <> ''
|
||||
ORDER BY p.rowid LIMIT 1)"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user