Implement max_models_by_field and unique field constraints#122
Draft
Copilot wants to merge 3 commits intoimprove-sosh-net-uifrom
Draft
Implement max_models_by_field and unique field constraints#122Copilot wants to merge 3 commits intoimprove-sosh-net-uifrom
max_models_by_field and unique field constraints#122Copilot wants to merge 3 commits intoimprove-sosh-net-uifrom
Conversation
Agent-Logs-Url: https://github.com/medium-tech/mspec/sessions/b14cb5cf-a10a-4577-a667-9dcc9cb85103 Co-authored-by: b-rad-c <25362581+b-rad-c@users.noreply.github.com>
…_by_field requires login, add comment for FK UNIQUE exclusion Agent-Logs-Url: https://github.com/medium-tech/mspec/sessions/b14cb5cf-a10a-4577-a667-9dcc9cb85103 Co-authored-by: b-rad-c <25362581+b-rad-c@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement max_models_by_field and unique constraints
Implement Apr 13, 2026
max_models_by_field and unique field constraints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two new data-integrity features: per-field creation limits per user (
max_models_by_field) and database-level unique column constraints (unique: true).max_models_by_fieldsrc/mspec/core.py: Defaultsmax_models_by_fieldto{}in all auth blocks; validates that it cannot be set withoutrequire_login: truesrc/mapp/module/model/db.py—db_model_create: After themax_models_per_usercheck, iteratesmax_models_by_fieldand raisesMappUserError('MAX_MODELS_BY_FIELD_EXCEEDED', ...)(→ HTTP 400) when exceededuniquefield constraintdb_model_create_table: AppendsUNIQUEto the SQLite column definition for non-list, non-foreign-key fields withunique: truedb_model_create: Catchessqlite3.IntegrityErrorand raisesMappUserError('UNIQUE_CONSTRAINT_VIOLATED', 'A record with that value already exists.')(→ HTTP 400)Tests & docs
limit_d(exercisesmax_models_by_field) andunique_test(exercisesunique: true) models tomodel-type-testing.yamlrun_server_crud_for_modelintest.pynow asserts HTTP 400 + correct error codes for both constraint typesdocs/LINGO_MAPP_SPEC.mddocuments the newauth.max_models_by_fielddict anduniquefield attribute