MemberJunction / MemberJunction/MJ
mj sync: the first push after a pull reports every record as updated
- Dominant language
- TSQL
- Stars
- 29
- Forks
- 6
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 323
Description
**Describe the bug**
The first `mj sync push` after an `mj sync pull` reports every record as updated, even though the files were just written from that same database and nothing changed in between. A second push of the same directory reports them all unchanged.
So a pull leaves the directory in a state the push does not recognise as current, and it takes a full write pass over every record to settle. That makes "what would this push change?" unanswerable right after a pull, and it writes rows (and their Record Changes) that did not need writing.
**To Reproduce**
1. Pull an entity directory: `mj sync pull --entity "MJ: Resource Types" --target-dir `
2. Push the directory it just wrote: `mj sync push --dir= --include= --ci`
3. Push it again, unchanged.
Observed against SQL Server on `next` (MJ 6.1.0-edge.6), 10 `MJ: Resource Types` records:
```
push after the pull: Created 0 Updated 10 Unchanged 0
push again: Created 0 Updated 0 Unchanged 10
```
Same with a 20-record Open App entity (`MJ_BizApps_Common: Organizations`): 20 updated, then 20 unchanged.
**Expected behavior**
A push straight after a pull of the same records reports them unchanged, because they are.
**Additional context**
Reproduces on `next` with no local changes — this is not a regression from the metadata-sync fixes in #4460 / #4461; I confirmed it by reverting those and re-running the same sequence.
Not verified, but worth checking first: the pulled files carry a `sync` block (`lastModified` + `checksum`), and push writes its own into the files it pushes. If the two sides compute that value differently, the first push would see every record as changed and its write-back would then make the second push agree — which matches the observed pattern. A related detail: the pulled file writes raw values where the repo's committed metadata uses `@lookup:` references, so the file content genuinely differs from what was committed, even though it describes the same rows.
Possibly related: #4529 — `--dry-run` reports every record as "Would update" even when a real push finds them unchanged. Different trigger, same area (change detection), filed separately.
Contributor guide
Research direction
Start by reproducing the sequence with `mj sync pull --entity` followed by `mj sync push --dir=... --include=... --ci`, then repeat the push. Compare the pulled files' `sync` values (`lastModified` and `checksum`) with the values written by push, including raw values versus `@lookup:` references. Done means the first push reports the records unchanged and does not write rows or Record Changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100