Part one ended with a recurring event stored as a rule, a time zone, and a handful of constraints that refuse to let me be clever. That's the calm part. It lasts until somebody clicks Edit.
Here's the scene. It's Wednesday night. The hockey team practices every Thursday at 18:00, and the arena has just flooded. The coach, or the treasurer, or whoever has the admin login this season, opens the calendar on their phone and wants to do one small thing: move this Thursday to Friday. Next week's Thursday is fine. The week after is fine. Only this one.
That phrase, "only this one", is where a calendar stops being a list and starts being a problem. In part one I deliberately didn't store 104 practices. I stored one rule that describes them, and I work out the individual practices on demand when somebody looks at a month. So this Thursday isn't a row. There's nothing to edit. The thing the coach is pointing at exists only because my code is currently imagining it.
So where does "move this one" go? And what about "move this one and every one after it", or "move all of them"? Every calendar product on earth answers with the same dialog, and you've seen it:
( ) This event
( ) This and following events
( ) All eventsIt looks like a radio group. It's actually three different database operations with three different blast radii, and the person choosing between them is usually in a hurry, in a cold parking lot, with one thumb.
A little vocabulary before we go on, because I'll use these words precisely. The master is the row that holds the rule. An occurrence is one practice the rule generates. An exception is a stored override of a single occurrence: moved, retitled or cancelled.
This part is about what each of those three buttons does to the database. It's also where I'll show you the longest-lived bug in this whole series, which was a bound parameter whose column I forgot to name.
Three radio buttons, three very different writes
Before any code, here's what each choice writes:
Scope | What changes | What stays |
|---|---|---|
This occurrence | One sparse row in | The master row, untouched |
This and following | Head series shortened, new tail series inserted, later exceptions handed to the tail | Earlier exceptions stay with the head |
All | One ordinary update to the master, then an audit of which exceptions still match | Everything else |
The form posts an edit_scope field with one of three values: occurrence, following or series. If it's missing, or anything else, the request is refused with a 422. It is never treated as a silent series edit. The radio defaults to the narrowest choice, occurrence, because the worst thing a default can do here is the widest thing.
The controller itself is thin enough to be embarrassing. Three scopes, three service calls, one responder:
if ( edit_scope == "occurrence" ) {
var occurrence_result = calendar_occurrence_action_service.processOccurrenceScopeEdit(
rc = arguments.rc,
occurrence_context = occurrence_context,
scope = arguments.scope,
scope_id = arguments.account_scope_id,
group_type = scopeGroupType( arguments.prc, arguments.scope, arguments.account_scope_id ),
language = arguments.prc.language, actor_user_id = actor_id );
respondOccurrenceResult( cb_event, prc, occurrence_result, "calendar_occurrence_updated" );
return;
}
// following
var split_result = calendar_occurrence_action_service.processFollowingScopeEdit(
rc = arguments.rc,
occurrence_context = occurrence_context,
scope = arguments.scope,
scope_id = arguments.account_scope_id,
group_type = scopeGroupType( arguments.prc, arguments.scope, arguments.account_scope_id ),
language = arguments.prc.language,
actor_user_id = actor_id
);
// At the series' first occurrence "this and following" IS the whole series:
// the service updated it in place and split nothing.
respondOccurrenceResult(
cb_event,
prc,
split_result,
( split_result.branch ?: "" ) == "whole_series" ? "calendar_event_updated" : "calendar_series_split_success"
);Those call lines are long enough to need a lie-down. I left them whole so you can see how little the controller decides.
Identity is the original slot
Here's the first design decision, and everything else depends on it.
If I move Thursday's practice to Friday, what is that occurrence now? Is it "the Friday one"? "The Thursday one that moved"? If I'm going to hang an exception off it, I need an answer that doesn't change when somebody drags it to another day.
An occurrence's identity is the instant the rule generated it. Not where it ended up. A 14-digit stamp of that original instant, yyyymmddHHnnss in UTC, is what goes into URLs, and an original_start_utc column carries it in the database. It never changes, however far the occurrence is later moved.
This matters more than it sounds. Links in sent emails point at that stamp. Reminder jobs are keyed by it. If identity followed the moved time, every one of those would silently re-point the first time somebody changed a start time.
One row, sparse
An exception is the smallest thing I could build that works. Here's the part of the table that does the heavy lifting:
-- Original occurrence identity (immutable).
original_start_utc timestamp with time zone NOT NULL,
original_starts_on date,
original_is_all_day boolean NOT NULL,
-- Lifecycle. Orphaning is orthogonal to status (see header).
status varchar(20) DEFAULT 'modified' NOT NULL,
orphaned_at timestamp with time zone,
-- Effective time override (atomic group; all NULL = inherit generated time).
starts_at_utc timestamp with time zone,
ends_at_utc timestamp with time zone,
timezone_iana text,
is_all_day boolean,
starts_on date,
ends_on_exclusive date,
-- Sparse content overrides (NULL = inherit; explicit clears live in cleared_fields).
title text,
summary text,
description text,
location_name text,
event_type_id uuid,
banner_asset_id uuid,
registration_mode varchar(20),
registration_id uuid,
external_url text,
settings_json jsonb DEFAULT '{}'::jsonb NOT NULL,
cleared_fields jsonb DEFAULT '[]'::jsonb NOT NULL,Two ideas hide in there.
NULL means "inherit." A column that's NULL says "I have no opinion, ask the master." So what do you do when somebody deliberately empties a field for one occurrence, which isn't the same as having no opinion? That's what cleared_fields is for. It holds the names of fields that were explicitly blanked, checked against an allowlist.
The time override is all-or-nothing. Six columns describe the effective time, and they're either all NULL or all present and mutually consistent. The database enforces it:
-- The atomic time-override group (see header). Mirrors V144's
-- ck_calevent_allday_date_model inside the override branch.
CONSTRAINT ck_calevent_exc_time_group CHECK (
(
starts_at_utc IS NULL AND ends_at_utc IS NULL AND timezone_iana IS NULL
AND is_all_day IS NULL AND starts_on IS NULL AND ends_on_exclusive IS NULL
)
OR (
starts_at_utc IS NOT NULL AND ends_at_utc IS NOT NULL AND timezone_iana IS NOT NULL
AND is_all_day IS NOT NULL
AND ends_at_utc > starts_at_utc
AND (
( is_all_day AND starts_on IS NOT NULL AND ends_on_exclusive IS NOT NULL AND ends_on_exclusive > starts_on )
OR ( NOT is_all_day AND starts_on IS NULL AND ends_on_exclusive IS NULL )
)
)
),That's the all-day date model from part one, repeated inside the override branch. It's a lot of constraint for one concept. I've decided I'd rather have the same rule written twice by a person than violated once by a bug.
There's also no group_id or organization_id on an exception. Scope is always reached through event_id, so a cross-tenant exception isn't something I have to defend against. It's something the schema can't represent.
The write
The "this occurrence" save is one statement. It's an upsert, and it carries its own concurrency guard:
ON CONFLICT ( event_id, original_start_utc ) WHERE deleted IS NULL
DO UPDATE SET
row_version = public.calendar_event_exception.row_version + 1,
orphaned_at = NULL,
status = EXCLUDED.status,
starts_at_utc = EXCLUDED.starts_at_utc,
...
cleared_fields = EXCLUDED.cleared_fields,
updated = now(),
updated_by_id = EXCLUDED.updated_by_id
WHERE public.calendar_event_exception.row_version = :expected_row_version
RETURNING id, row_version;The form carries the row_version it loaded. If somebody else got there first, the WHERE doesn't match, nothing is returned, and the caller gets a 409. And for a brand-new exception, the expected version is 0, which can never match a real row, so a racing create fails closed too.
Before it writes, the service computes a sparse diff against the master. A field that differs becomes an override. A field emptied while the master has a value goes into cleared_fields. A field equal to the master stays NULL.
That last rule has a lovely consequence. If somebody edits an occurrence and puts everything back the way it was, the diff is empty, and I delete the exception instead of storing a no-op:
if ( !arguments.diff.has_overrides && !arguments.was_cancelled ) {
// Nothing differs from the series: remove any existing exception
// (edit-back-to-inherit) instead of storing a no-op row.
var existing = calendar_event_exception_service.getActiveByIdentity(
arguments.master_id, arguments.generated.occurrence_start_utc
);
if ( !isNull( existing ) ) {
calendar_event_exception_service.softDelete( existing.getId(), arguments.actor_user_id );
return { success: true, deleted_redundant: true };
}
return { success: true, deleted_redundant: false };
}And through all of this, the master row is untouched. There's a spec that checks the master's row_version is still 1 after an occurrence edit. It's the most boring assertion in the project and it carries the whole design.
Cancel is not delete
Cancelling one occurrence is the same table with status = 'cancelled'. I made two deliberate choices there.
First, it's idempotent. The upsert's WHERE status <> 'cancelled' OR orphaned_at IS NOT NULL means that cancelling something already cancelled changes nothing, returns no rows, and the caller can tell.
Second, existing overrides are kept. If Thursday's practice had been moved to Friday and retitled, then cancelled, the exception row keeps the move and the title. When somebody restores it, everything comes back. If the row carries any override, restore flips it to modified. If it was a pure cancellation with nothing else on it, restore soft-deletes the row and the occurrence becomes plain generated time again.
A cancelled occurrence doesn't disappear from the calendar views either. It stays visible but inert, shown as cancelled. A Thursday that's quietly missing looks exactly like a Thursday that never existed, and the second one is how you get a parent standing in a parking lot. (What the iCalendar feed does with a cancellation is a different decision, and it's in part three.)
Its pending reminders are cancelled on the spot, not at the next sweep. A reminder for a cancelled practice is a much worse email than no email.
"This and following" is a split
This is the one I was afraid of. There's no way to express "from here on, the title is different" as an exception, because an exception is one occurrence. The honest model is two series: the old one stops, a new one starts.
The first step is pure arithmetic with no database in it, and I'm rather proud of how little arithmetic it is. I don't compute "the 14th Thursday" from frequency and interval. I generate the real occurrences and find the one with the matching identity:
var generated = calendar_recurrence_service.expandEventOccurrences(
arguments.master_struct,
dateAdd( "s", -1, series_start ),
dateAdd( "d", 800, series_start ),
true
);
var split_index = 0;
for ( var generated_index = 1; generated_index <= arrayLen( generated ); generated_index++ ) {
if ( generated[ generated_index ].occurrence_start_utc.getTime() == identity_utc.getTime() ) {
split_index = generated_index;
break;
}
}
if ( split_index == 0 ) return { ok: false, code: "occurrence_not_found" };
if ( split_index == 1 ) return { ok: true, mode: "whole_series" };Two things fall out of that.
If the requested stamp isn't something the rule generates, there's nothing to split at, and the answer is a refusal, not a guess. And if the occurrence is the first one, there's nothing to keep in front, so "this and following" is just "all", and the split quietly degrades to a plain series edit of the same row.
I did not handle that second case well the first time. For a while the route announced "Series split. This and following occurrences now form a new series." in response to an edit that had split nothing. I recorded it as found and deliberately not fixed, pinned it with a test, and fixed it a few weeks later. A message that's confidently wrong is the most reassuring kind.
One transaction
The split itself is four steps in one transaction. Any throw rolls all of it back.
transaction {
try {
// 1. Shorten the original series.
var end_mode = lCase( trim( toString( arguments.original_master.getRecurrence_end_mode() ?: "" ) ) );
if ( end_mode == "end_after_count" ) {
arguments.original_master.setRecurrence_count( arguments.plan.before_count );
// Derived-end convention: the start of the (new) final occurrence.
arguments.original_master.setRecurrence_end_date( dateTimeFormat( arguments.plan.last_before_start_utc, "yyyy-mm-dd HH:nn:ss" ) );
} else {
// end_by_date: end one second before the split original start.
arguments.original_master.setRecurrence_end_date( dateTimeFormat( dateAdd( "s", -1, arguments.plan.split_start_utc ), "yyyy-mm-dd HH:nn:ss" ) );
}
calendar_event_service.update(
calendar_event = arguments.original_master,
expected_row_version = arguments.expected_row_version
);
// ...
// 2. The tail master (its own fresh public identity) - and the
// LINEAGE back to the head (Phase 8, V149).
// ...
arguments.new_master.setSplit_origin_event_id( original_id );
arguments.new_master.setSplit_origin_start_utc( arguments.plan.split_start_utc );
// ...
calendar_event_service.insert( arguments.new_master );
var new_id = toString( arguments.new_master.getId() );
// 3. Move the tail's exceptions - identities preserved.
calendar_event_exception_service.reassignFromSplit(
from_event_id = original_id,
to_event_id = new_id,
split_original_start_utc = arguments.plan.split_start_utc,
actor_user_id = arguments.actor_user_id
);
// 4. Reconcile BOTH sides against their new rules.
reconcileMasterExceptions( arguments.original_master, arguments.actor_user_id );
var tail_reconcile = reconcileMasterExceptions( arguments.new_master, arguments.actor_user_id );
result = {
success: true,
new_event: arguments.new_master,
orphaned_count: calendar_event_exception_service.countOrphansForEvent( original_id )
+ calendar_event_exception_service.countOrphansForEvent( new_id )
};
} catch ( Rosterli.Calendar.StaleEventVersion stale_version_error ) {
transactionRollback();
result = { success: false, code: "stale_version" };
} catch ( any split_error ) {
transactionRollback();
rethrow;
}
}That's the transaction as shipped, with the // ... lines marking what I left out: a long comment in step two, which I'll paraphrase in the "breadcrumb" section below, and two lines of bookkeeping that stamp the tail with the kind of split it came from and the reminder choice it inherits.
Some details in there are deliberate:
- One second. The head ends at the split instant minus one second because the walker treats
recurrence_end_dateas the last accepted instant, inclusive. If I ended it at the split instant, the original occurrence would belong to both series and everybody would see it twice. - Count mode sets
recurrence_countto the number of occurrences kept, and re-derives the end date. The end date has to stay populated, because part one's constraint says so. - The tail isn't a clone. It's built from the posted form, the same way a create is, anchored at whatever start time the administrator submitted. The editor pre-fills that form from the original, which is why it feels like a copy. It isn't one. I mention it because for a while a code comment of mine claimed otherwise.
- Exceptions follow the territory. Every exception at or after the split instant moves to the tail by changing its
event_id. Itsoriginal_start_utcis never touched, so identity survives the move.
Here's one series being split at its second occurrence, with an exception on each side of the line:
BEFORE H: O1 ---- O2 ---- O3(cancelled via X3) ---- O4(moved via X4) ---- O5 ---- O6
AFTER H: O1 |
T: | O2 ---- O3(cancelled via X3) ---- O4'(moved via X4) ---- O5 ---- O6
H.recurrence_end_date = O2 - 1 second
T.split_origin_event_id = H
T.split_origin_start_utc = O2 <- the ORIGINAL identity
X3.event_id, X4.event_id = T <- moved; original_start_utc unchangedThe reminder rules are copied to the tail after the transaction commits. If that copy fails, I log a warning and the split stands. It's the one thing I let go outside the transaction, deliberately, because I'd rather have a split with missing reminder rules than no split. That's a trade-off and I'm not going to pretend otherwise.
Orphans, not casualties
Now the question that keeps me up. What happens to an exception whose original occurrence stops existing?
It happens constantly. The administrator edits the series so practices move from 18:00 to 19:00. Every original identity the rule used to generate has just stopped being generated. Every moved or cancelled occurrence is suddenly attached to nothing.
I don't delete them, and I don't re-attach them to something similar. After every series edit and on both sides of every split, I run a reconcile:
for ( var exception_row in listActiveForEvent( arguments.event_id, true ) ) {
// Phase 5: the feed sync reconciles MANAGED rows against the
// source's own desired set (which includes RDATE identities the
// rule never generates) - orphan-stamping is for administrator
// rows only in that path.
if ( arguments.skip_external_managed && ( exception_row.getIs_external_managed() ?: false ) ) continue;
var identity_key = toString( exception_row.getOriginal_start_utc().getTime() );
var matches = structKeyExists( arguments.valid_identity_milliseconds, identity_key );
var is_orphaned = !isNull( exception_row.getOrphaned_at() ) && isDate( exception_row.getOrphaned_at() ?: "" );
if ( matches && is_orphaned ) {
setOrphanedState( exception_row.getId(), false, arguments.actor_user_id );
revived++;
} else if ( !matches && !is_orphaned ) {
setOrphanedState( exception_row.getId(), true, arguments.actor_user_id );
orphaned++;
}
}The skip_external_managed branch is the feed importer's, and it comes back in part three. For the administrator's own exceptions, the two calls to setOrphanedState are the whole story: revive what matches again, orphan what no longer matches.
An exception whose identity the rule no longer generates gets orphaned_at = now(). It isn't displayed and it isn't deleted. If a later edit makes the rule generate that identity again, it's revived.
I'll be honest about the part I don't love. The help text says orphaned exceptions are "set aside for review." There's no review screen. The administrator gets a count appended to the success message, once, and that's the whole surface. The data is kept, and a person can't currently see it. I went looking for that screen while preparing this article so I could show it to you. There isn't one.
The breadcrumb
Here's why the tail carries split_origin_event_id and split_origin_start_utc.
An email went out last month with a link to "Thursday, December 16 practice." That link points at the head series and carries the 14-digit stamp for December 16. Since then, somebody split the series and renamed the tail. The head no longer generates December 16. What does the old link do?
Without lineage, it does the worst possible thing: it works. It falls back to the head's nearest occurrence, usually an earlier one. The visitor lands on a page that's confident, well formatted, and about the wrong Thursday. That includes the links in reminders that were already sent, which can never be edited.
So the page asks the lineage. It walks forward from the head to the latest tail whose boundary is at or before the requested instant, re-asserting the tenant on every hop:
SELECT
CAST(id AS text) AS id
FROM
public.calendar_event
WHERE
split_origin_event_id = CAST(:origin_id AS uuid)
AND split_origin_start_utc <= :wanted
AND deleted IS NULL
#scope_sql#
ORDER BY
split_origin_start_utc DESC
LIMIT 1It's capped at ten hops. The comment above the cap says a series split ten times is already pathological. I stand by that comment and I'm not going to stand near the person who proves it wrong.
The boundary stored is the original identity of the split occurrence, not the tail's new start. If the administrator retimes the tail while splitting, the tail starts at 13:00 but the boundary stays at the original 17:00Z, because the boundary describes what the head stopped owning. That's exactly what the old-link walk needs, and there's a spec that pins it with three different timestamps so nobody can "simplify" it.
The parameter I bound and never named
Time to tell you about the bug.
The split's INSERT statement built a parameter struct with both lineage values in it. The values went in. The code reviewed fine. The specs were green. The column list and the VALUES list both skipped from recurrence_count straight to created_by_id.
For six weeks, every split tail was written with both lineage columns NULL.
Nothing failed. Splits split. Tails existed. The only visible symptom was the one I just described: an old link, landing quietly on the wrong date. The fix, when it came, was two lines:
recurrence_count,
split_origin_event_id,
split_origin_start_utc,
:recurrence_count,
CAST( :split_origin_event_id AS uuid ),
:split_origin_start_utc,(Those are the lines as they stand today. Other columns have since been added around them, but the two lineage names now sit in both lists, which is the whole fix.)
I've spent more time wondering why the tests stayed green than why the code was wrong. The lineage tests seeded the lineage columns with a raw UPDATE and then tested the walk. They proved the walk worked. They never proved that a split wrote anything, and a comment in the test file even said those cases "stay green even when a split persists nothing." That was an accurate description of the problem, sitting in plain sight, and nobody read it as a warning.
What found it was a different test, the first one that drove a real split through the real route. It noticed the empty value, and, because it was part of a refactor that wasn't allowed to change behaviour, it pinned the empty value as "FOUND, NOT FIXED" and moved on. A bug, documented, and then sat on.
When I did fix it, I wanted to know whether production already held any splits written without lineage. A tail with no breadcrumb looks like any other series, so I went looking for the fingerprint of the split's own rewrite. The split writes its end date as the split instant minus one second, :59.000. The form writes :59.999 or :00.000. I checked four signals, including that one.
Production had 18 recurring events and none of them looked like a split tail. There was nothing to backfill. I'll admit to being slightly disappointed. I'd built a very nice detective story with no victim.
The fix that needed a fix first
Now the part where fixing the bug would have created a worse one.
The lineage column has a foreign key back to the head, with ON DELETE SET NULL, because deleting a head must not delete its tails. It also has a CHECK saying the two lineage columns are either both NULL or both set:
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fk_calevent_split_origin'
AND conrelid = 'public.calendar_event'::regclass
) THEN
ALTER TABLE public.calendar_event
ADD CONSTRAINT fk_calevent_split_origin
FOREIGN KEY (split_origin_event_id)
REFERENCES public.calendar_event (id)
ON DELETE SET NULL;
END IF;
END
$$;
-- Both lineage columns are set together or neither is: a boundary without an
-- origin cannot be walked, and an origin without a boundary cannot say WHICH
-- occurrences moved. A row may never be its own origin.
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'ck_calevent_split_origin'
AND conrelid = 'public.calendar_event'::regclass
) THEN
ALTER TABLE public.calendar_event
ADD CONSTRAINT ck_calevent_split_origin CHECK (
(split_origin_event_id IS NULL AND split_origin_start_utc IS NULL)
OR (
split_origin_event_id IS NOT NULL
AND split_origin_start_utc IS NOT NULL
AND split_origin_event_id <> id
)
);
END IF;
END
$$;
(The DO blocks are just the migration's idempotency guards, so it can be re-run safely. The two ADD CONSTRAINT statements are the point.)Read those together. When the head is deleted, SET NULL clears one column, split_origin_event_id. The CHECK then notices that the other column, split_origin_start_utc, is still set, and refuses the row. The delete of the head fails on the tail's constraint.
That schema had been wrong since the day it shipped. It stayed invisible for exactly one reason: because of the bug above, no tail had ever carried lineage, so there was never a row for the CHECK to object to. Fixing the INSERT alone would have turned "permanently delete a split series' head" into a 500.
So the order mattered, and it mattered by fourteen seconds. The first commit made the delete path detach the tails, in one statement, clearing the lineage columns. (The statement below is today's version. A third lineage column, recording what kind of split produced the tail, joined later, and the delete clears it along with the other two.)
WITH detached_split_tails AS (
UPDATE public.calendar_event
SET split_origin_event_id = NULL,
split_origin_start_utc = NULL,
split_origin_kind = NULL
WHERE split_origin_event_id = CAST( :id AS uuid )
)
DELETE FROM public.calendar_event
WHERE id = CAST( :id AS uuid );The second, fourteen seconds later, named the columns in the INSERT. I'd like to claim that was elegant planning. It was a careful git commit followed by a second careful git commit.
That fixes one code path. It doesn't fix the schema, which is the thing that's actually wrong. A bare DELETE in a console, a calendar's ON DELETE CASCADE taking out a head whose tail is in another calendar, a purge job: none of those go through my application's delete function. So the schema gets a second layer, a trigger on the exact column the foreign key writes to:
CREATE OR REPLACE FUNCTION public.calendar_event_split_origin_pair() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
-- The FK's ON DELETE SET NULL clears the origin id alone; the boundary
-- belongs with it (ck_calevent_split_origin), so it goes in the same write.
IF NEW.split_origin_event_id IS NULL AND OLD.split_origin_event_id IS NOT NULL THEN
NEW.split_origin_start_utc := NULL;
END IF;
RETURN NEW;
END;
$$;
-- ...
DROP TRIGGER IF EXISTS calendar_event_split_origin_pair_trg ON public.calendar_event;
CREATE TRIGGER calendar_event_split_origin_pair_trg
BEFORE UPDATE OF split_origin_event_id ON public.calendar_event
FOR EACH ROW EXECUTE FUNCTION public.calendar_event_split_origin_pair();The foreign key's SET NULL is an ordinary update of that column, so it fires the trigger, and the boundary goes with the id in the same write. It's one-directional on purpose. Clearing only the boundary is still refused by the CHECK.
I kept the application-layer clearing too. The application's intent should stay visible in the code, and I apply production migrations by hand, which means the schema can legitimately be a deploy behind the code. Old code, new schema, and new code, old schema all keep working.
The test for the trigger is my favourite test in the repository, because it contains a control. It runs the delete and watches it succeed. Then it disables the trigger, runs the same delete, and asserts that the database refuses it on the CHECK. Then it re-enables the trigger. The header of that file says: "A guard that cannot fail proves nothing."
The bugs that were always there
A few smaller ones, because they belong in the same pile.
Editing an occurrence 500'd the first time anyone tried. My service function returned null when no exception row existed, which is true of every pristine series. In Adobe ColdFusion, assigning a null to a local variable leaves the variable undefined. A bare isObject( exception ) then throws "Variable EXCEPTION is undefined" instead of returning false. The first edit of any occurrence of any untouched series returned a 500, and the panel closed quietly so the change just vanished. The commit message says the feature "has never worked." There's now a test that scans the source for a bare isObject( exception ) and fails the build if it finds one.
false counted as "missing." ColdFusion's elvis operator returns its default when the left side is boolean false. My exception writer used it, so every timed override wrote is_all_day as NULL and violated the time-group constraint, which was the one doing its job. The column that was NULL was literally named for the thing that was false.
Concurrency is opt-in. My series update only checks row_version when the caller supplies one. A form that doesn't post a version updates unguarded. The exception upsert is strict in the other direction. I'd like to say I made that asymmetry on purpose. I'm saying it's documented, which is the nearest I can honestly get.
What I'd keep
- Identity is the original slot, not where an occurrence ended up.
- NULL means "inherit". Explicit clears get their own column.
- An edit that equals the series removes the exception. Don't store no-ops.
- "This and following" is a split, and a split is one transaction.
- Orphan, don't delete. And if the data is kept "for review," build the review.
- When a test seeds the column it's meant to prove gets written, it's testing the reader and not the writer.
- A foreign key action and a CHECK constraint can disagree with each other, and the database won't tell you until the row exists.
Next: my calendar leaves the building. I publish a feed that Google, Apple and Outlook will each interpret slightly differently, and then I do the more dangerous thing and let a customer paste in a URL that my server will go and fetch.
