Skip to content

Upsert on save#117

Merged
Electron100 merged 2 commits intomasterfrom
upsert
Jun 27, 2023
Merged

Upsert on save#117
Electron100 merged 2 commits intomasterfrom
upsert

Conversation

@Electron100
Copy link
Owner

@Electron100 Electron100 commented Jun 18, 2023

Address #112

@Electron100
Copy link
Owner Author

Missing tests, for one thing

@Electron100 Electron100 changed the title WIP: Upsert on save Upsert on save Jun 25, 2023
@Electron100 Electron100 marked this pull request as ready for review June 25, 2023 14:18
@Electron100 Electron100 merged commit d15fe87 into master Jun 27, 2023
@Electron100 Electron100 deleted the upsert branch June 27, 2023 02:10
Electron100 added a commit that referenced this pull request Nov 1, 2023

ObjectState never really took on as large a role I had originally envisioned, while at the same time being quite clunky -- an extra field automatically injected into all model types. It had a single member saved, which tracks whether the object had previously been saved or not. Most of the time this doesn't matter though, especially since #117 changed save to upsert. I believe the only remaining case where it does matter is for automatic creation of primary keys, and those were operating in a semantic grey area where creating an unitialized primary key required setting it to -1 or similar.

This change does the following

1. Removes ObjectState and the auto-created state member for each model
2. Adds a new AutoPk<T> type which is used as the type for fields which represent automatic primary keys. This tracks whether the primary key has already been generated or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants