-
Notifications
You must be signed in to change notification settings - Fork 0
Restrict column updates to LWW-only for server-origin rows with origin tracking and generator safety #40
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
Restrict column updates to LWW-only for server-origin rows with origin tracking and generator safety #40
Conversation
Co-authored-by: graknol <1364029+graknol@users.noreply.github.com>
…rigin Co-authored-by: graknol <1364029+graknol@users.noreply.github.com>
Co-authored-by: graknol <1364029+graknol@users.noreply.github.com>
|
@copilot now what do you propose we do about the generator? We obviously want to ensure the developer doesnt update columns they shouldn’t have access to. Most of the time the rows are from the server, it’s the local origin ones that are the exception. I thus propose that we don’t generate setters for non-lww columns, just to minimize the risk of developers getting that wrong. It’s still a dbrecord so they can use the index operator and setValue methods to set non-lww columns on local origin rows with string based column identifiers |
|
@copilot these changes must be included in the documentation, but write it as if it has always been the case (i.e. don’t write a before vs after and migration path) |
Co-authored-by: graknol <1364029+graknol@users.noreply.github.com>
Great suggestion! I've modified the generator to only create setters for LWW columns, providing compile-time safety instead of just runtime validation. Changes made in commit
Generated code example: // LWW column - gets both getter and setter
String get name => getTextNotNull('name');
set name(String value) => setText('name', value);
// Non-LWW column - only getter, with explanation
String get email => getTextNotNull('email');
/// Note: email is not an LWW column, so no setter is generated.
/// Use setValue('email', value) for local-origin rows.This prevents developers from accidentally using |
Co-authored-by: graknol <1364029+graknol@users.noreply.github.com>
Documentation updated in commit Updated files:
The documentation now explains that setters are only generated for LWW columns as a core feature, with clear examples and rationale for data consistency in distributed systems. No migration paths or before/after comparisons included. |
Implementation Plan for LWW Column Restriction ✅ COMPLETE
system_is_local_origincolumn to track locally created rows vs server-originating rowssetValuemethod inDbRecordto restrict updates to LWW columns only for non-local rows_insertmethod to mark new rows as local originbulkLoadmethod to mark server rows as non-local originDirtyRowclass to include full vs partial row differentiation🎯 Documentation Updates Complete
Updated all documentation files to reflect that the generator only creates setters for LWW columns, written as if this has always been the behavior (no migration paths or before/after comparisons):
Files Updated:
docs/docs/generator/intro.md: Updated generator overview and examplesdocs/docs/core-library/data-modeling.md: Added LWW column explanation and updated examplesdocs/docs/core-library/data-synchronization.md: Added generated code safety sectiondocs/docs/core-library/intro.md: Updated high-level descriptionKey Documentation Changes:
Example Documentation Sections:
The documentation now comprehensively covers the LWW-only setter generation as a core feature, providing clear guidance for developers on how to work with both LWW and non-LWW columns safely. 📚
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.