GITHUB · FOUNDATIONS
GitHub pull request basics: review a SQL diff, checks and merge
A pull request (PR) proposes integrating changes into another branch. Follow a small SQL edit that excludes a previously selected report. Read its effect, then distinguish human review, automated checks and merging—all within this lesson.
Explain the effect on three stipulated rows and identify which change was reviewed, tested and integrated.
A commit records history; a branch names a position in it. SQL expresses a data query. The WHERE and AND conditions used here are explained below.
Start by reading what changed
Imagine PR #42 in the fictional repository demo-acme/report-infra, proposing feature/jp-report-filter into main. Base is the destination; head is the proposed branch. No GitHub account or PR is created.
SELECT report_id, report_month
FROM reports
-WHERE approval = 'approved';
+WHERE approval = 'approved'
+ AND region = 'JP';SELECT names output columns, FROM names the table, and WHERE filters rows. Previously a row needed approval = approved; it now also needs region = JP. AND requires both predicates. This changes a read query, not the stored rows.
Trace the effect on three rows
| Report | approval | region | Before | After |
|---|---|---|---|---|
| R-A | approved | JP | Included | Included |
| R-B | approved | US | Included | Excluded |
| R-C | pending | JP | Excluded | Excluded |
R-B is newly excluded. R-A satisfies both predicates; R-C was never approved. The expected sets are {R-A, R-B} before and {R-A} after. All rows are stipulated to have report_month = 2026-09, but the SQL has no month filter. It also has no ORDER BY, so output order is unspecified.
A useful review question is: “Will excluding R-B break a consumer that needs US reports?” A small diff can have a large effect. Real data would also require checking NULL handling, string comparison, month scope and downstream consumers. First explain the effect on these three rows.
Separate human review from automated checks
| View | Question to answer |
|---|---|
| Files changed | Which lines changed, and how? |
| Conversation | What purpose, questions and decisions were recorded? |
| Commits | Which revisions form the proposal? |
| Checks | Which validations were reported, and for which revision? |
A review can Comment, Approve or Request changes. These are human decisions, separate from an automated check. A syntax check cannot establish agreement to exclude US rows. Checks may also come from integrations other than Actions.
Required approvals, checks and bypasses depend on repository rules, permissions and plan. An approval alone does not necessarily allow merging. When more changes arrive, review the current diff and whether the earlier approval still applies; automatic dismissal of stale approval is configurable.
Track which revision was tested
B is the common ancestor; H is the proposed head. Here main is also B.
A person evaluates the diff and whether excluding R-B is intended.
T labels a synthetic test-merge revision, distinct from head H.
Recheck the current diff, reviews and checks; label the result M.
Build from M, then verify the destination and application behavior separately.
Arrows indicate stages to consider, not successful executions. B, H, T and M are teaching labels, not actual commit hashes.
A GitHub PR normally shows changes from the merge base—the common ancestor—to the proposed head. B is fixed as that ancestor here. The current base-branch tip need not equal the comparison base. If main advances, check what was compared and tested.
For an open, mergeable PR, a pull_request workflow using the default ref tests a generated merge revision, labelled T here. Distinguish GITHUB_SHA from github.event.pull_request.head.sha. A different checkout target or event can test something else.
Updating the proposal or main can change the test target. Evidence about T cannot simply be relabelled as evidence about a future integration M or a deployed artifact.
What remains after merging?
- Identify integrated revision M; merge commits, squash and rebase produce history differently.
- Build an artifact from M and record its input. report-sql-bundle@M is a fictional name here.
- Verify that the intended artifact reached staging; integration into main alone does not deploy it.
- Read from the destination and verify expected behavior. Transfer success alone does not establish business correctness.
Check your reading of the change
Choose an option to see the result and explanation.
Check, then explain in your own words
- Explain which row the added AND predicate excludes.
- Write one requirement question a reviewer should ask.
- Distinguish proposed H, tested T and integrated M.
Check your understanding: “Approved and checks passed—users have the change now.” Is that established?
No. Integration, build, delivery and user-visible behavior need separate checks.
A review decision and a check of a specific revision do not establish completion of later stages.
Sources and conditions checked
Primary references are collected here with their scope, conditions and corresponding sections. Independent expert review and live-environment validation have not been performed.
- GitHub: Pull requestsChecked:
Scope and conditionsProposals, PR views and merge refs; current base tip versus common ancestor. Documentation review, not live-environment validation.
Used in this lessonStart by reading what changed Separate human review from automated checks What remains after merging? Check your reading of the change
- GitHub: Pull request reviewsChecked:
Scope and conditionsComment, Approve and Request changes decisions. Documentation review, not live-environment validation.
Used in this lessonStart by reading what changed Separate human review from automated checks
- GitHub: About protected branchesChecked:
Scope and conditionsPlan, visibility and configured checks, reviews and stale approval handling. Documentation review, not live-environment validation.
Used in this lessonSeparate human review from automated checks Track which revision was tested Check your reading of the change
Scope and conditionsA three-dot PR diff compares the merge base with the proposed head, unlike a two-dot comparison of current tips. Documentation review, not live-environment validation.
Used in this lessonTrack which revision was tested
Scope and conditionsDefault pull_request merge ref versus head.sha for open mergeable PRs; other events and checkout targets differ. Documentation review, not live-environment validation.
Used in this lessonTrack which revision was tested Check your reading of the change
Scope and conditionsUntrusted code and privileged contexts, secrets, third-party actions and persistent self-hosted state. Documentation review, not live-environment validation.
Used in this lessonWhat remains after merging?