pub struct Table { /* private fields */ }Expand description
ONE node’s storage in ONE database: the table, its columns, the columns an index seeks it by, the columns a UNIQUE index constrains, and the edge tables its collections hang off.
§It is an ITEM, and every part of it is &'static
new is const and takes borrowed lists, which is RecordAddress’s shape one
layer up and for its reason: a schema is DECLARED, once, beside the record it describes, and a
descriptor built per boot would be a schema that could differ between two of them. A &[…]
written in a let is E0716, so a descriptor is spelled in a const — which is where it
already is, on the Describe impl that carries it.
§Five members and the split layout’s two
The address is the table’s NAME and its key columns, so it is not restated here; the columns are
the row’s own, each with the type this database keeps it at; the indexes are the FIELDS a plain
index is created over, one apiece; the uniques are the fields a UNIQUE index constrains, held
apart from the indexes for with_uniques’s own reason; and the edges are
its collections’ second tables. Beside the edges sits the one list that is about a collection
this dialect keeps in a COLUMN — see
with_collection_indexes, which is indexed’s array-storage
half. The last two are the split layout’s, and they arrive together — see
with_provenance.
§TWO CONSTRUCTORS, and the difference is who spells a column’s NAME
new takes the FLAT list a person writes: one entry per column, its name spelled
out. shaped takes the row’s own ColumnShape list with the word this
database stores each FIELD at beside it, and leaves the names to the renderer — which is what an
EMISSION can hand over, tb_num being a join and a const here having no joining rule.
Everything else composes onto both identically: with_indexes, with_uniques, with_edges,
with_shadows and with_provenance each ask whether a name is one of the table’s own columns,
and each road answers that its own way. See TableColumns, where the partition is stated, and
shaped, where the checks a shaped descriptor is held to are.
§Examples
A record with a two-column key, one nullable column, one indexed field and a sequence:
use ingraph::{Column, EdgeShape, EdgeTable, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(
FieldName::new("clip"),
&[FieldName::new("media_id"), FieldName::new("id")],
),
&[
Column::new(FieldName::new("media_id"), "INTEGER", false),
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("title"), "TEXT", true),
],
)
.with_indexes(&[FieldName::new("title")])
.with_edges(&[EdgeTable::new(
&[FieldName::new("tags")],
EdgeShape::Sequence,
"TEXT",
)]);
assert_eq!(CLIP.address().table(), FieldName::new("clip"));
assert_eq!(CLIP.columns().width(), 3);
assert_eq!(CLIP.stored(FieldName::new("id")), "INTEGER");Implementations§
Source§impl Table
impl Table
Sourcepub fn create<Db: AsyncSchemaDialect>(
&self,
) -> Result<Vec<String>, SqlLoweringError>
Available on crate feature sqlx only.
pub fn create<Db: AsyncSchemaDialect>( &self, ) -> Result<Vec<String>, SqlLoweringError>
sqlx only.Every statement that creates this node’s storage, in the order it has to run.
The parent table, then one statement per UNIQUE field, then one per COMPOSITE unique, then one
per remaining indexed field, then one per COLLECTION COLUMN that asked for the value-led path
where this dialect keeps a collection in one, then each upstream’s provenance table, then each
collection’s edge table with its own containment index where the collection is a SEQUENCE and
the VALUE-LED index beside it where the collection wrote indexed. Nothing here executes: the
list IS the schema, which is what makes a rendering assertion see exactly what an engine would.
The two UNIQUE loops are adjacent because they render the same KIND of statement from two
declarations — one column apiece and several — and neither is deduplicated against the other:
a pair that would collide is refused where the descriptor is written, which is
Table::with_composite_uniques’s own check and the reason nothing here has to look.
The parent table leads because the provenance tables’ foreign keys name it, and a dialect that checks a constraint as it creates it would have nothing to point at.
§A field named in BOTH indexes and uniques renders the unique statement ALONE
A unique index already answers what a plain one over the same column exists for — a seek by
that value — so a second, plain CREATE INDEX beside it would name the identical column for
the identical purpose and cost every future write a second structure to maintain: a redundant
write amplifier, not a second capability. Table::with_indexes and
Table::with_uniques do not refuse the overlap — an author who wrote indexed beside
unique on one field stated two intents about it, a seek and a constraint, and the spelling
stays legal — it is THIS method, reading both lists together, that satisfies both with the one
statement the unique index already is. A field named only in indexes is unaffected: it
renders exactly the plain statement it always has.
§No column type is refused here, and a dialect that cannot index one says so ITSELF
Neither loop below asks what a field’s column is stored AS before naming it in a CREATE INDEX/CREATE UNIQUE INDEX — the check AsyncSchemaDialect::SORT_KEY_INDEX runs for the
companion loop beneath this one does not apply here, because that constant answers for ONE
column type this dialect controls and a declared field’s column may be typed at anything the
declaration named. So a TEXT/BLOB field marked indexed or unique under MySQL renders a
statement this dialect refuses at CREATE INDEX … ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length — the same honest failure an over-wide plain index
already reached before unique existed, at the engine, on a connection the caller had already
opened, rather than a silent narrowing this crate would have to guess a prefix width for.
§Errors
SqlLoweringError::EdgeWithoutField, which is [edge]’s own refusal for a collection path
naming no field. It is unreachable from a descriptor — EdgeTable::new refuses the empty
path in a const — and it is still carried rather than unwrapped, because [edge] is the ONE
derivation every party spelling an edge table’s names goes through and a second, infallible
copy of it would be the second spelling this whole module exists to avoid.
Source§impl Table
impl Table
Sourcepub const fn new(address: RecordAddress, columns: &'static [Column]) -> Self
pub const fn new(address: RecordAddress, columns: &'static [Column]) -> Self
The table address names, carrying columns, with no index, no edge table and no
discriminant.
The three absent members are the COMMON case and each is added by a method of its own, so a
record with no collection and no index states two arguments rather than five — which is what
keeps the shape readable where it is actually written, inside a const beside a record.
§A key column is one of the table’s OWN columns, and that is checked here
The key columns are what an edge table’s rows lead with and what its PRIMARY KEY names, so
the DDL has to know the type each is stored at — and it reads that off columns. A key naming
a column the table does not carry is therefore a descriptor with no rendering, and it is
refused where it is written:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("media_id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
);Its positive twin, for the reason EdgeTable::new’s pair carries one:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
);
assert!(CLIP.columns().width() == 1);Sourcepub const fn shaped(
address: RecordAddress,
columns: &'static [ColumnShape],
words: &'static [&'static [&'static str]],
nulls: &'static [bool],
) -> Self
pub const fn shaped( address: RecordAddress, columns: &'static [ColumnShape], words: &'static [&'static [&'static str]], nulls: &'static [bool], ) -> Self
The table address names, whose columns are the row’s own SHAPES with the word this database
stores each FIELD at beside them — the same table, stated the way an emission can state it.
Table::new &[Column::new(FieldName::new("tb_num"), "INTEGER", false), …] names joined
Table::shaped COLUMNS, &[<Timebase as StoredAs<Db>>::WORDS, …], &[false, …] names rendered§The names are NOT here, and that is the whole of what the word buys
A flat descriptor spells tb_num, which is the join written down — so an emission producing
one would have to concatenate a name in a const, where this crate has no joining rule by
design (see ColumnShape’s own module, and FieldName, which states it does not
join). What arrives here instead is the list the query layer already publishes, and the join
happens where every other spelling of that column happens: at render time, through
push_segments, which a SELECT of tb_num and a filter over tb.num both reach. A shaped
CREATE TABLE therefore cannot name a column the read lane would not find.
§Three lists at the FIELD’s grain, and the WIDTH is what holds them together
columns is by field. So words is one StoredAs::WORDS per field
— one word per COLUMN that field spans, flattened, in SEGMENTS
order — and nulls is one flag per field. Each field’s word count is held against its own
width in a const, which is the agreement spans asserts one type at a time
and this asserts for a whole row:
use ingraph::{ColumnName, ColumnShape, FieldName, RecordAddress, Table};
const COLUMNS: &[ColumnShape] = &[ColumnShape::Composite {
field: Some(ColumnName::new("tb")),
segments: &[
ColumnShape::Plain(ColumnName::new("num")),
ColumnShape::Plain(ColumnName::new("den")),
],
}];
// TWO columns wide, and ONE word offered for them.
const CLIP: Table = Table::shaped(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("tb_num")]),
COLUMNS,
&[&["INTEGER"]],
&[false],
);§NULLABILITY IS TWO GRAINS, and nulls states only the DECLARATION’s
One flag per field says the whole field may be ABSENT, which is what
StoredAs’s Option<T> row already means — an absent value leaves every
column of the field NULL. It is the optional marker, and a marker sits on a field.
It cannot say that ONE of a composite’s columns holds NULL while its siblings do not, and
there is a shipped type that wants exactly that:
MediaTimeRange’s two DERIVED nanosecond columns bind NULL for an
endpoint past i64 nanoseconds while its tick counts stay exact. That fact is not a third
list here. It is stated by the TYPE, beside the segment it belongs to, as
ColumnShape::Nullable — so it arrives through columns and
needs no seat of its own.
The renderer composes the two: a column admits NULL when its FIELD is optional or when
its LEAF says so. A required span: MediaTimeRange renders its four value columns NOT NULL
and its two derived ones bare — which is the schema its own write path promised and, while the
field grain was the only one, could not have been given.
A derived leaf is not thereby a nullable one. NOT NULL is kept off the leaves that say
Nullable, and a leaf whose computation is total says
Derived instead and takes it —
BoundingBox’s area is the shipped case. Both are outside the VALUE;
only one of them may be NULL.
What stays the declaration’s is the whole-field absence, and the division is the honest one: a marker author knows whether a field may be missing, and only the TYPE knows which of its columns are the value.
§A COLLECTION field is not here either, exactly as it is not in a flat descriptor
A collection is an EdgeTable — it appears in no column list, which is the partition
with_edges states — so it is in neither columns nor words, and
StoredAs having no Vec<T> row in any dialect is the same fact from the
other side. The one collection that could be a COLUMN is a PostgreSQL ARRAY, whose declared
spelling and whose catalogue spelling are two different strings; StoredAs’s own note records
that no single WORDS can be both, and nothing in this crate stores one today. So an array
column has no word to hand this constructor, and that is where the question stays until
something needs one.
§Examples
A record with a composite field, and the six columns it renders under one:
use ingraph::{ColumnName, ColumnShape, FieldName, RecordAddress, Table};
const TIMEBASE: &[ColumnShape] = &[
ColumnShape::Plain(ColumnName::new("num")),
ColumnShape::Plain(ColumnName::new("den")),
];
const COLUMNS: &[ColumnShape] = &[
ColumnShape::Plain(ColumnName::new("id")),
ColumnShape::Composite { field: Some(ColumnName::new("tb")), segments: TIMEBASE },
];
const CLIP: Table = Table::shaped(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
COLUMNS,
&[&["INTEGER"], &["INTEGER", "INTEGER"]],
&[false, true],
);
assert_eq!(CLIP.columns().width(), 3);
// The joined name is not stored — it is ASKED FOR, and answered by the same walk the
// renderer makes.
assert_eq!(CLIP.stored(FieldName::new("tb_den")), "INTEGER");§A KEY column is one of the columns the shapes RENDER, and that is checked here
new’s own refusal, asked of a shaped descriptor: the key is compared against
each column the fields join to, through joins, which is the const family’s
whole knowledge of the join and is a COMPARISON rather than a lookup — so the check is made
without a name ever being built.
use ingraph::{ColumnName, ColumnShape, FieldName, RecordAddress, Table};
const COLUMNS: &[ColumnShape] = &[ColumnShape::Plain(ColumnName::new("id"))];
const CLIP: Table = Table::shaped(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("media_id")]),
COLUMNS,
&[&["INTEGER"]],
&[false],
);A key naming a SEGMENT is admitted, because a segment is a column: the join is what decides, not the nesting.
use ingraph::{ColumnName, ColumnShape, FieldName, RecordAddress, Table};
const COLUMNS: &[ColumnShape] = &[ColumnShape::Composite {
field: Some(ColumnName::new("tb")),
segments: &[ColumnShape::Plain(ColumnName::new("num"))],
}];
const CLIP: Table = Table::shaped(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("tb_num")]),
COLUMNS,
&[&["INTEGER"]],
&[false],
);
assert_eq!(CLIP.columns().width(), 1);Sourcepub const fn with_indexes(self, indexes: &'static [&'static FieldName]) -> Self
pub const fn with_indexes(self, indexes: &'static [&'static FieldName]) -> Self
The same table with one index per named FIELD.
A field rather than a column list, because that is what the declaration says: an index is asked for at a field, and its NAME is derived from the table and the column so that nothing spells one twice. A composite index over several columns is a different declaration and is not expressible here — said rather than left for a reader to try, since the list’s shape looks as though it might be one.
§Every indexed field is one of THIS table’s OWN columns, and that is checked here
The statement this list renders names the column directly — CREATE INDEX … ON <table> (<field>) — so a field the table does not carry is an index over a column no CREATE TABLE
ever declared, and the ENGINE would be the first party to say so, at boot, on a connection the
caller had already opened. The two members beside this one refuse their own version of that
where the descriptor is written, and this one now lands the same way:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_indexes(&[FieldName::new("title")]);Its positive twin, for the reason EdgeTable::new’s pair carries one:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("title"), "TEXT", true),
],
)
.with_indexes(&[FieldName::new("title")]);
assert_eq!(CLIP.indexes().len(), 1);A COMPANION column is not named here and does not have to be: it is none of the record’s own
columns — see Shadow, where that partition is stated — and the walk indexes every one of
them itself, where the dialect can index a binary column with no key length.
The check reads self.columns, which new has already settled, so this call may
be written in any position among its neighbours — the property with_shadows
states for the same reason.
Sourcepub const fn with_uniques(self, uniques: &'static [&'static FieldName]) -> Self
pub const fn with_uniques(self, uniques: &'static [&'static FieldName]) -> Self
The same table with one UNIQUE index per named FIELD.
with_indexes’s own shape, one word over: a field rather than a column
list, its NAME derived the same way, and a composite constraint over several columns is the
same different declaration this list does not express either.
§A field named here and ALSO in indexes renders ONE statement, not two
A unique index already answers what a plain one seeks a row by, so a column carrying both
words has nothing left for the plain statement to do that the unique one has not — the
dedup, and the argument for it, are Table::create’s, which is where both lists are read
together. This method does not refuse the overlap: an author who wrote indexed beside
unique on one field stated two intents about it, and the SPELLING stays legal even though
the render collapses it to the index that already implies the other.
§Every unique field is one of THIS table’s OWN columns, and that is checked here
The same check with_indexes runs, for the same reason: the statement
this list renders names the column directly, so a field the table does not carry is a
constraint over a column no CREATE TABLE ever declared.
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_uniques(&[FieldName::new("checksum")]);Its positive twin:
use ingraph::{Column, FieldName, RecordAddress, Table};
const ASSET: Table = Table::new(
RecordAddress::new(FieldName::new("asset"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("checksum"), "TEXT", false),
],
)
.with_uniques(&[FieldName::new("checksum")]);
assert_eq!(ASSET.uniques().len(), 1);The check reads self.columns, so this call may be written in any position among its
neighbours — with_indexes’s own property, for the same reason.
Sourcepub const fn with_composite_uniques(
self,
composites: &'static [CompositeUnique],
) -> Self
pub const fn with_composite_uniques( self, composites: &'static [CompositeUnique], ) -> Self
The same table with one UNIQUE index per COMPOSITE constraint — the declaration
with_uniques states it does not express.
Each CompositeUnique names the row’s own entries and the renderer joins what they resolve
to; see that type, where the two kinds of entry and the value-leaf fan are stated, and
create, where the statement is.
§THIS CALL COMES AFTER with_uniques, and the order is load-bearing
The collision check below reads self.uniques, so a chain that writes this first would check
against an empty list and admit the very pair it exists to refuse. It is the property
with_shadows already carries for with_edges, and
it is the one place this family’s write these in any order freedom does not hold.
§Every entry names something THIS table carries, and that is checked here
with_uniques’s own check, widened by exactly what this list widens: an
entry may name a LEAF column, as that one does, or a CITIZEN whose value leaves the statement
names instead. What it may not name is neither — a column no CREATE TABLE ever declared:
use ingraph::{Column, CompositeUnique, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_composite_uniques(&[CompositeUnique::new(&[
FieldName::new("id"),
FieldName::new("checksum"),
])]);Its positive twin, for the reason EdgeTable::new’s pair carries one:
use ingraph::{Column, CompositeUnique, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("checksum"), "TEXT", false),
],
)
.with_composite_uniques(&[CompositeUnique::new(&[
FieldName::new("id"),
FieldName::new("checksum"),
])]);
assert_eq!(CLIP.composite_uniques().len(), 1);§A CITIZEN WITH NO VALUE LEAVES is refused, rather than rendered as nothing
An entry that resolves to a citizen contributes that citizen’s value leaves, and a citizen
whose every leaf is derived has none — see CompositeUnique, where the exclusion and its
reason are. Rendering it would emit a statement naming fewer columns than the author wrote, or
none at all; so the descriptor refuses it, and the sentence says which of the two facts is
wrong.
§AN EXACT DUPLICATE IS REFUSED, and it is never deduplicated
Two declarations of the same constraint derive the SAME NAME, and the second CREATE UNIQUE INDEX IF NOT EXISTS over it is a statement the engine discards — a silent no-op, which is
exactly the outcome an author who wrote the constraint twice needs told about. So the
collision is the tell and it is refused here, in both directions it can arrive:
- TWO COMPOSITES naming the same entries in the same order;
- A SINGLE-ENTRY COMPOSITE naming a column
uniquesalready names — the two roads meeting on one column, which derives__ig_<table>_<column>from either road.
A different ORDER is a different constraint and collides with neither: (a, b) and (b, a)
derive different names and serve different seeks. See CompositeUnique, where the order’s
own meaning is stated.
use ingraph::{Column, CompositeUnique, FieldName, RecordAddress, Table};
const ASSET: Table = Table::new(
RecordAddress::new(FieldName::new("asset"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("checksum"), "TEXT", false),
],
)
.with_uniques(&[FieldName::new("checksum")])
.with_composite_uniques(&[CompositeUnique::new(&[FieldName::new("checksum")])]);Sourcepub const fn with_edges(self, edges: &'static [EdgeTable]) -> Self
pub const fn with_edges(self, edges: &'static [EdgeTable]) -> Self
The same table with the second tables its collections are stored in.
A collection column named here is NOT among columns, which is the partition
SqlQuery::COLLECTIONS already draws from the
query side: a gathered column has no value on the parent row, so a CREATE TABLE that named
one would declare a column no statement ever writes.
Sourcepub const fn with_collection_indexes(
self,
collections: &'static [&'static FieldName],
) -> Self
pub const fn with_collection_indexes( self, collections: &'static [&'static FieldName], ) -> Self
The same table with the VALUE-LED access path over each named COLLECTION COLUMN —
EdgeTable::indexed’s other half, for the dialect that keeps a collection in a column of the
row instead of in a second table.
CREATE INDEX IF NOT EXISTS "__ig_clip_tags_value" ON "clip" USING GIN ("tags")§ONE word, two storage forms, and the NAME is the same string in both
An edge table’s name IS the row’s table run together with the column’s path, so the index this
list renders and the one EdgeTable::indexed renders for the same collection derive the
SAME identifier — __ig_clip_tags_value whether clip.tags is a second table or an array
column. That is not a coincidence to be worked around: a collection has ONE containment index
in whichever database is holding it, and a reader looking at two catalogues sees one name.
§A dialect with NO array column renders nothing for this list
The access method is AsyncSchemaDialect::COLLECTION_INDEX
and it is None on the two dialects that have no array type — where every collection is
already a second table, so a descriptor for them carries no such column to name and this list
is empty by construction. The precedent for a dialect dropping an index it cannot make is
AsyncSchemaDialect::SORT_KEY_INDEX,
where MySQL’s ERROR 1170 is measured.
§Every named collection is one of THIS table’s OWN columns, and that is checked here
with_indexes’ own check, for its reason: the statement names the column
directly, so a field this table does not carry is an index over one no CREATE TABLE declared.
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "bigint", false)],
)
.with_collection_indexes(&[FieldName::new("tags")]);Its positive twin, for the reason EdgeTable::new’s pair carries one:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "bigint", false),
Column::new(FieldName::new("tags"), "text[]", false),
],
)
.with_collection_indexes(&[FieldName::new("tags")]);
assert_eq!(CLIP.collection_indexes().len(), 1);Sourcepub const fn with_shadows(self, shadows: &'static [Shadow]) -> Self
pub const fn with_shadows(self, shadows: &'static [Shadow]) -> Self
The same table with an ORDER-PRESERVING COMPANION COLUMN per sortable collection — see
Shadow.
§Every companion names one of THIS table’s edge tables, and that is checked here
A companion is the order of a collection kept in a table of its own, so a path naming no edge
table of this row is a column that mirrors nothing: the write lane would have no elements to
encode and the ORDER BY would order by whatever was last written into it. The refusal lands
where the descriptor is written:
use ingraph::{Column, FieldName, RecordAddress, Shadow, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_shadows(&[Shadow::new(
FieldName::new("__ig_tags_sort__"),
&[FieldName::new("tags")],
)]);Its positive twin, for the reason EdgeTable::new’s pair carries one — and the shape a
sortable collection’s descriptor actually takes, both halves together:
use ingraph::{Column, EdgeShape, EdgeTable, FieldName, RecordAddress, Shadow, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_edges(&[EdgeTable::new(
&[FieldName::new("tags")],
EdgeShape::Sequence,
"TEXT",
)])
.with_shadows(&[Shadow::new(
FieldName::new("__ig_tags_sort__"),
&[FieldName::new("tags")],
)]);
assert_eq!(CLIP.shadows().len(), 1);The ORDER of the two calls does not matter — the check reads self.edges, which
new leaves empty, so a with_shadows written first refuses for the same reason
a companion naming a scalar column does. That is the honest failure: a descriptor whose two
halves are stated in either order is one a reader can write from memory, and the one shape that
cannot be spelled is a companion with no collection.
Sourcepub const fn with_provenance(
self,
source: &'static FieldName,
sides: &'static [SideTable],
) -> Self
pub const fn with_provenance( self, source: &'static FieldName, sides: &'static [SideTable], ) -> Self
The same table under the SPLIT LAYOUT: source names the discriminant column, and sides
are the provenance tables one variant’s ancestors go in apiece.
§The discriminant is one of the table’s OWN columns
It is stored, selected, bound and read back like every other column, so it is declared like
every other column and this names WHICH of them it is. A second, appended column would be one
the row’s own list does not carry — and describes holds that list against the query
layer’s, so the drift would be a compile error one direction and an unwritable column the
other.
§Both halves at once, because a layout is not half a layout
A discriminant with no provenance table names a row whose ancestry is stored nowhere; a provenance table with no discriminant leaves a reader to open each of them in turn to find out which one holds the row. Neither is a state a descriptor should be able to spell, so both arrive in one call and each is refused where it is written:
use ingraph::{Column, FieldName, RecordAddress, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[Column::new(FieldName::new("id"), "INTEGER", false)],
)
.with_provenance(FieldName::new("__ig_source__"), &[]);Its positive twin, for the reason EdgeTable::new’s pair carries one:
use ingraph::{Column, FieldName, RecordAddress, SideTable, Table};
const CLIP: Table = Table::new(
RecordAddress::new(FieldName::new("clip"), &[FieldName::new("id")]),
&[
Column::new(FieldName::new("id"), "INTEGER", false),
Column::new(FieldName::new("__ig_source__"), "TEXT", false),
],
)
.with_provenance(
FieldName::new("__ig_source__"),
&[SideTable::new(
FieldName::new("clip_frame"),
&[Column::new(FieldName::new("media_id"), "INTEGER", false)],
)],
);
assert_eq!(CLIP.sides().len(), 1);Sourcepub const fn address(&self) -> RecordAddress
pub const fn address(&self) -> RecordAddress
The table this node is stored in, and the key columns identifying one of its rows.
Sourcepub const fn columns(&self) -> TableColumns
pub const fn columns(&self) -> TableColumns
Every column of the parent table, in the order the DDL declares them — as the descriptor STATES them, which is one of two roads.
TableColumns is where the two are, and a caller that wants one of them says which:
flat for the names a hand-written descriptor carries,
shapes for the fields an emitted one hands over. What both answer is
width, which is the question a caller counting columns is asking.
Sourcepub const fn indexes(&self) -> &'static [&'static FieldName]
pub const fn indexes(&self) -> &'static [&'static FieldName]
The fields a PLAIN index is created over, one apiece.
A field named ALSO in uniques still appears here — this list is what was
DECLARED — and it is Table::create that reads the two together and renders the one
statement the pair implies.
Sourcepub const fn uniques(&self) -> &'static [&'static FieldName]
pub const fn uniques(&self) -> &'static [&'static FieldName]
The fields a UNIQUE index constrains, one apiece.
Sourcepub const fn composite_uniques(&self) -> &'static [CompositeUnique]
pub const fn composite_uniques(&self) -> &'static [CompositeUnique]
The COMPOSITE unique constraints, each over the entries it names.
Held apart from uniques rather than folded into it, because the two carry
different things: that list is one column apiece, and an entry here may be a citizen the
renderer fans. See CompositeUnique.
Sourcepub const fn edges(&self) -> &'static [EdgeTable]
pub const fn edges(&self) -> &'static [EdgeTable]
The second tables this node’s collections are stored in.
Sourcepub const fn collection_indexes(&self) -> &'static [&'static FieldName]
pub const fn collection_indexes(&self) -> &'static [&'static FieldName]
The COLLECTION COLUMNS of this row that take the value-led containment index — see
with_collection_indexes.
Empty on every dialect with no array type, where a collection is a second table and the word
lands on EdgeTable::indexed instead.
Sourcepub const fn shadows(&self) -> &'static [Shadow]
pub const fn shadows(&self) -> &'static [Shadow]
The order-preserving companion columns this node’s sortable collections are mirrored into —
empty for a node that declared none, which is every node written before the word existed.
Sourcepub const fn source(&self) -> Option<&'static FieldName>
pub const fn source(&self) -> Option<&'static FieldName>
The discriminant column, where the layout carries one — one of columns, and
which of them a row’s upstream is read out of.
Sourcepub const fn sides(&self) -> &'static [SideTable]
pub const fn sides(&self) -> &'static [SideTable]
The provenance tables one variant’s ancestors go in apiece — empty for a node whose ancestry is columns of its own row.
Sourcepub const fn id(&self) -> &'static FieldName
pub const fn id(&self) -> &'static FieldName
The column a row is identified by — the key’s LAST, key = lineage ⊕ id being root-first.
The one column a provenance table points back at, and the one the schema declares UNIQUE so
that it can: a foreign key names a parent column the parent table constrains uniquely, and
create’s own UNIQUE (<id>) is what makes that true for a lineage-bearing
record. A ROOT’s key is its id, so the primary key already carries it.
Sourcepub const fn stored(&self, column: &FieldName) -> &'static str
pub const fn stored(&self, column: &FieldName) -> &'static str
The type this database stores column at.
Infallible, and new is what makes it so for the one caller that has to be sure:
the DDL asks this for every KEY column, and a key naming a column the table does not carry is
refused in a const before any rendering. A column that is neither a key nor one of the
table’s own has no type to answer with, and asking is the caller’s error rather than the
table’s.
A SHAPED descriptor answers the same question through the join rather than through a name it
carries: the column is compared against what each field’s segments run together into, by
joins, and the word is the one its field states for that leaf. So a key
column that is a SEGMENT — tb_num under a tb — is answered exactly as a top-level field is.
§Panics
Where column is not one of columns.
Trait Implementations§
impl Copy for Table
impl Eq for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<K> PositionKey for K
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> RootKey for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.